SUGGESTED FIX
--- old/src/share/classes/java/awt/Window.java 2008-08-21 17:47:25.000000000 +0400
+++ new/src/share/classes/java/awt/Window.java 2008-08-21 17:47:25.000000000 +0400
@@ -3204,6 +3204,12 @@
Container c = root.getContentPane();
javax.swing.JComponent content =
(c instanceof javax.swing.JComponent) ? (javax.swing.JComponent)c : null;
+ javax.swing.JComponent gp =
+ (rpc.getGlassPane() instanceof javax.swing.JComponent) ?
+ (javax.swing.JComponent)rpc.getGlassPane() : null;
+ if (gp != null) {
+ gp.setDoubleBuffered(isOpaque);
+ }
lp.setOpaque(isOpaque);
//lp.setDoubleBuffered(isOpaque); //XXX: this might be needed maybe...
root.setOpaque(isOpaque);
|
EVALUATION
When the window is non-opaque, and it needs to be repainted the sun.awt.windows.TranslucentWindowPainter (see src/windows/classes/sun/awt/windows/TranslucentWindowPainter.java) creates an ARGB_PRE buffered image and uses the Frame.paintAll(Graphics) method to paint the frame contents to the buffered image. The resulting image gets painted on the screen then.
I modified the given test case so that the button action handler include the following code before and after setting the glass pane visible:
BufferedImage i1 = new BufferedImage(frame.getWidth(), frame.getHeight(),
BufferedImage.TYPE_INT_ARGB_PRE);;
frame.paintAll(i1.getGraphics());
try {
javax.imageio.ImageIO.write(i1, "png", new File("before.png"));
} catch (IOException e1) {
e1.printStackTrace();
}
(the one located after showing the glass pane saves the image to the after.png file.) The resulting files and the modified test case are attached to the change request.
Obviously, the Swing paints the glass pane as an opaque panel, and therefore we observe this result on the screen. To fix the bug the Swing painting machinery must not paint the background of the glass pane (which is by default a non-opaque panel - it is unclear why Swing paints its background.).
|