-
Bug
-
Resolution: Fixed
-
P2
-
1.1
-
1.1fcs
-
generic, x86
-
solaris_10, windows_nt
-
Not verified
/*
** Stephen Blackheath 14 Dec 96
** This version of repaint doesn't work on 1.1 beta!
** The workaround is either to change 'paintAll(g)' to paint(g),
** or to remove the 'g.dispose()'.
*/
public void repaint() {
Graphics g = getGraphics();
if ( g == null ) return;
paintAll(g);
g.dispose();
}
The problem is that Component.paintAll does this:
public void paintAll(Graphics g) {
ComponentPeer peer = this.peer;
if (visible && (peer != null)) {
validate();
peer.paint(g);
}
}
peer.paint(..) is routed to sun.awt.motif.MComponentPeer.paint, which
does this:
public void paint(Graphics g) {
g.setColor(target.getForeground());
g.setFont(target.getFont());
postEvent(new PaintEvent(target, PaintEvent.PAINT, g));
//target.paint(g);
}
In the beta version, 'target.paint(g)' was changed to 'postEvent(new PaintEvent
....'. The problem is that this queues a request to paint rather than
painting immediately. By the time the paint is called, the Graphics
object has already been dispose()'d by the caller (the Visible Human Project
code).
This needs to be done in another way!
** Stephen Blackheath 14 Dec 96
** This version of repaint doesn't work on 1.1 beta!
** The workaround is either to change 'paintAll(g)' to paint(g),
** or to remove the 'g.dispose()'.
*/
public void repaint() {
Graphics g = getGraphics();
if ( g == null ) return;
paintAll(g);
g.dispose();
}
The problem is that Component.paintAll does this:
public void paintAll(Graphics g) {
ComponentPeer peer = this.peer;
if (visible && (peer != null)) {
validate();
peer.paint(g);
}
}
peer.paint(..) is routed to sun.awt.motif.MComponentPeer.paint, which
does this:
public void paint(Graphics g) {
g.setColor(target.getForeground());
g.setFont(target.getFont());
postEvent(new PaintEvent(target, PaintEvent.PAINT, g));
//target.paint(g);
}
In the beta version, 'target.paint(g)' was changed to 'postEvent(new PaintEvent
....'. The problem is that this queues a request to paint rather than
painting immediately. By the time the paint is called, the Graphics
object has already been dispose()'d by the caller (the Visible Human Project
code).
This needs to be done in another way!
- duplicates
-
JDK-4039552 PaintEvent.PAINT cause the screen cleared and disable double buffering
- Closed