Resizing a JInternalFrame in a non-opaque JFrame may lead to throwing the sun.java2d.InvalidPipeException. It also produces a visual garbage on the screen.
It is reproducible with 6u10b27 on Vista.
EXCEPTION STACK TRACE:
****************************************************
Exception in thread "AWT-EventQueue-0" sun.java2d.InvalidPipeException: bounds c
hanged or surface lost
at sun.java2d.pipe.BufferedContext.validate(Unknown Source)
at sun.java2d.pipe.BufferedContext.validateContext(Unknown Source)
at sun.java2d.pipe.BufferedContext.validateContext(Unknown Source)
at sun.awt.windows.TranslucentWindowPainter$VIOptWindowPainter.update(Un
known Source)
at sun.awt.windows.TranslucentWindowPainter.updateWindow(Unknown Source)
at sun.awt.windows.WWindowPeer.updateWindow(Unknown Source)
at java.awt.Window.updateWindow(Unknown Source)
at java.awt.Window.access$900(Unknown Source)
at java.awt.Window$1.updateWindow(Unknown Source)
at javax.swing.RepaintManager.updateWindows(Unknown Source)
at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source)
at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source)
at javax.swing.RepaintManager.seqPaintDirtyRegions(Unknown Source)
at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(Unknow
n Source)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
****************************************************
TEST APPLICATION:
****************************************************
import javax.swing.*;
import java.awt.*;
import javax.swing.border.*;
import java.lang.reflect.*;
public class NonOpaqueWindowTest2 extends JFrame
{
public NonOpaqueWindowTest2()
{
super();
setWindowNonOpaque(this);
JDesktopPane desktop = new JDesktopPane();
JInternalFrame iFrame = new JInternalFrame("Test", true, true, true, true);
iFrame.add(new JLabel("internal Frame"));
iFrame.setBounds(10, 10, 300, 200);
iFrame.setVisible(true);
desktop.add(iFrame);
getContentPane().add(desktop);
setTitle(getClass().getSimpleName());
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(400, 400);
setLocationRelativeTo(null);
setVisible(true);
}
private void setWindowNonOpaque(Window w)
{
try
{
Class<?> c = Class.forName("com.sun.awt.AWTUtilities");
Method m = c.getMethod("setWindowOpaque", Window.class, boolean.class);
m.invoke(null, w, false);
}
catch (Exception e)
{
e.printStackTrace();
}
}
public static void main(String[] args) throws Exception
{
EventQueue.invokeLater(new Runnable(){
public void run()
{
JFrame.setDefaultLookAndFeelDecorated(true);
new NonOpaqueWindowTest2();
}
});
}
}
****************************************************
STEPS TO REPRODUCE:
1. Run the application with 6u10b27 on Vista (I've verified it having Aero theme enabled).
2. Start resizing the internal frame with the mouse.
3. The exception stack trace is printed on the console.
The issue is reported here:
http://forums.java.net/jive/thread.jspa?threadID=43881&tstart=0