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

Window transparency throws IAE if called before pack or setSize

    XMLWordPrintable

    Details

    • Subcomponent:
    • Introduced In Version:
    • Resolved In Build:
      b01
    • CPU:
      generic
    • OS:
      windows_vista
    • Verification:
      Verified

      Backports

        Description

        Window transparency throws IAE if called before pack or setSize. The test case below throws IAE. However, if pack is moved before the call to setWindowOpaque, all is fine.

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

        public class TPTest extends JFrame {
            
            public TPTest() {
                super("TPTest");
                
                add(new JButton("Hi!"));
            }

            private static void createAndShowGUI(String[] args) {
                TPTest test = new TPTest();
                test.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                //test.setSize(400, 400);
                //test.setLocationRelativeTo(null);
                //test.setVisible(true);
                test.setUndecorated(true);
                com.sun.awt.AWTUtilities.setWindowOpaque(test, false);
                test.pack();
                test.setVisible(true);
            }
            
            public static void main(final String[] args) {
                SwingUtilities.invokeLater(new Runnable() {
                    public void run() {
                        createAndShowGUI(args);
                    }
                });
            }
        }

        IAE:

        Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: Width (0) and height (0) cannot be <= 0
        at java.awt.image.DirectColorModel.createCompatibleWritableRaster(DirectColorModel.java:999)
        at sun.awt.image.SunVolatileImage.getBackupImage(SunVolatileImage.java:225)
        at sun.awt.image.VolatileSurfaceManager.getBackupSurface(VolatileSurfaceManager.java:252)
        at sun.awt.image.VolatileSurfaceManager.initialize(VolatileSurfaceManager.java:108)
        at sun.awt.image.SunVolatileImage.<init>(SunVolatileImage.java:72)
        at sun.awt.image.SunVolatileImage.<init>(SunVolatileImage.java:101)
        at java.awt.GraphicsConfiguration.createCompatibleVolatileImage(GraphicsConfiguration.java:284)
        at java.awt.GraphicsConfiguration.createCompatibleVolatileImage(GraphicsConfiguration.java:218)
        at sun.awt.windows.TranslucentWindowPainter$VIWindowPainter.getBackBuffer(TranslucentWindowPainter.java:279)
        at sun.awt.windows.TranslucentWindowPainter.updateWindow(TranslucentWindowPainter.java:131)
        at sun.awt.windows.WWindowPeer.updateWindow(WWindowPeer.java:652)
        at sun.awt.windows.WWindowPeer.setOpaque(WWindowPeer.java:639)
        at java.awt.Window.applyOpaque(Window.java:3299)
        at java.awt.Window.addNotify(Window.java:652)
        at java.awt.Frame.addNotify(Frame.java:469)
        at java.awt.Window.pack(Window.java:686)
        at TPTest.createAndShowGUI(TPTest.java:21)
        at TPTest.access$000(TPTest.java:5)
        at TPTest$1.run(TPTest.java:28)
        at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
        at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  anthony Anthony Petrov (Inactive)
                  Reporter:
                  shickeysunw Shannon Hickey (Inactive)
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  0 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Imported:
                    Indexed: