Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6388546

PNG with transparent background doesn't render correctly

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 6
    • Fix Version/s: 6
    • Component/s: client-libs
    • Labels:
    • Subcomponent:
      2d
    • Resolved In Build:
      b77
    • CPU:
      x86
    • OS:
      windows_xp

      Description

      /*

      If you run this app with the attached PNG image ("test.png") in
      the same directory you'll see that the lightbulb image's background
      is white - not transparent. However viewing the same image with
      Microsoft's tools shows that the image has a transparent background.
      As well it should, since it was saved that way using IrFanView 3.98,
      a freeware image editor.

      */

      import java.awt.*;
      import java.awt.event.*;
      import javax.swing.*;
      import javax.swing.event.*;

      public class Test {
         JFrame mainFrame = null;

         void initialize(String[] ignore) {
             Icon icon = new ImageIcon("test.png");
             mainFrame = new JFrame("Image should have transparent background");
             Container cp = mainFrame.getContentPane();
             cp.setBackground(Color.green);
             mainFrame.add(new JLabel(icon));
         }

         void show() {
             mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
             mainFrame.pack();
             mainFrame.setVisible(true);
         }

         public static void main(final String[] args) throws Exception {
             Runnable doCreateAndShowGUI = new Runnable() {
                 public void run() {
                     try {
                         Test app = new Test();
                         app.initialize(args);
                         app.show();
                     }
                     catch (Exception e) {
                         // TBD log an error
                     }
                 }
             };
             SwingUtilities.invokeLater(doCreateAndShowGUI);
         }
      }

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              bae Andrew Brygin
              Reporter:
              svioletsunw Scott Violet (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: