Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 6750920
Votes 0
Synopsis Window transparency throws IAE if called before pack or setSize
Category java:classes_awt
Reported Against b30
Release Fixed 6u12(b01)
State 10-Fix Delivered, Verified, bug
Priority: 2-High
Related Bugs
Submit Date 22-SEP-2008
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)
Posted Date : 2008-09-22 14:21:45.0
Work Around
Call pack() before enabling the transparency mode.
Evaluation
We need to check if the window is zero-sized in the WWindowPeer.updateWindow(). If so, the updateWindow() request should be ignored.
Posted Date : 2008-09-23 10:30:07.0
Comments
  
  Include a link with my name & email   


PLEASE NOTE: JDK6 is formerly known as Project Mustang