-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
1.4.0
-
x86
-
windows_2000
Name: jk109818 Date: 01/24/2002
FULL PRODUCT VERSION :
java version "1.4.0-beta3"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta3-b84)
Java HotSpot(TM) Client VM (build 1.4.0-beta3-b84, mixed mode)
FULL OPERATING SYSTEM VERSION :
Microsoft Windows 2000 [Version 5.00.2195]
A DESCRIPTION OF THE PROBLEM :
If you create an applet using GridBagLayout and
GridBagConstraints, the background of the applet doesn't
get refreshed correctly. This bug only effects the
background. Any other components do get updated
correctly. I didn't try other layouts, but I suspect the
bug also effects them.
I tried the following applet in IE 5.5, Netscape 4.78,
Netscape 6.X and Mozilla 0.97. The same problems occur in
all of them:
1) When you minimize the browser and restore it, the applet
background displays what was behind that part of the
browser window when you minimized it.
2) When, with the applet displayed inside the browser, you
move another window around above the applet, bits and
pieces of that window get displayed in the applet
background.
Here's the source code of an applet that will always
reproduce the problem:
package refreshbug;
import java.awt.*;
import java.awt.event.*;
import java.applet.Applet;
import java.util.*;
import java.security.*;
public class RefreshBug extends Applet
{
protected Button button;
public void init() {
button = new Button("Button");
GridBagLayout gridBag =
new GridBagLayout();
setLayout(gridBag);
GridBagConstraints c =
new GridBagConstraints();
c.gridx = 0;
c.gridy = 0;
c.gridwidth = GridBagConstraints.CENTER;
c.insets = new Insets(10,20,20,10);
gridBag.setConstraints(button,c);
add(button);
}
}
This bug can be reproduced always.
CUSTOMER WORKAROUND :
Here's the same applet with source added to work around the
background refresh bug. You need to add a paint method
which completely clears the rectangle to be updated.
Oddly, you also need to fire a MOUSE_MOVED event to force
the background to actually be cleared. And in order for
the event to be received (and for this solution to work)
you need to add an AWT event listener for mouse motion
events. But that's only possible in a signed applet.
package refreshbug;
import java.awt.*;
import java.awt.event.*;
import java.applet.Applet;
import java.util.*;
import java.security.*;
public class RefreshBug extends Applet
{
protected Button button;
public void init() {
button = new Button("Button");
GridBagLayout gridBag =
new GridBagLayout();
setLayout(gridBag);
GridBagConstraints c =
new GridBagConstraints();
c.gridx = 0;
c.gridy = 0;
c.gridwidth = GridBagConstraints.CENTER;
c.insets = new Insets(10,20,20,10);
gridBag.setConstraints(button,c);
add(button);
final AWTEventListener cat =
new AWTEventListener()
{
public void eventDispatched
(AWTEvent e)
{
}
};
AccessController.doPrivileged
(new PrivilegedAction()
{
public Object run() {
getToolkit().addAWTEventListener
(cat,AWTEvent.
MOUSE_MOTION_EVENT_MASK);
return null;
}
});
}
public void paint(Graphics g) {
Rectangle clip = g.getClipBounds();
g.clearRect(clip.x,clip.y,clip.width,
clip.height);
MouseEvent scamper = new MouseEvent(this,
MouseEvent.MOUSE_MOVED,
new Date().getTime(),0,
(clip.width-clip.x)/2,
(clip.height-clip.y)/2,0,
false);
dispatchEvent(scamper);
}
}
Release Regression From : 1.3.1
The above release value was the last known release where this
bug was knwon to work. Since then there has been a regression.
(Review ID: 138482)
======================================================================
- duplicates
-
JDK-4374079 Win32:Lightweight components do not immediately repaint in response to repaint()
- Resolved