We can only paint a component without doublebuffering when all of it's ancestors are also double buffering disabled. Otherwise the screen and the backbuffer get out of sync and we get massive flickering. See the bugreport
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28027 for an example and why I think that this is the right fix. 2006-06-15 Roman Kennke <[EMAIL PROTECTED]> PR 28027 * javax/swing/JComponent.java (paintImmediately2): Only paint component without double buffering when all of it's parents have also double buffering disabled. (isPaintingDoubleBuffered): New helper method. /Roman -- “Improvement makes straight roads, but the crooked roads, without Improvement, are roads of Genius.” - William Blake
Index: javax/swing/JComponent.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/JComponent.java,v
retrieving revision 1.127
diff -u -1 -0 -r1.127 JComponent.java
--- javax/swing/JComponent.java 14 Jun 2006 11:01:24 -0000 1.127
+++ javax/swing/JComponent.java 15 Jun 2006 13:28:35 -0000
@@ -2132,28 +2132,48 @@
/**
* Performs the actual work of paintImmediatly on the repaint root.
*
* @param r the area to be repainted
*/
void paintImmediately2(Rectangle r)
{
isRepainting = true;
RepaintManager rm = RepaintManager.currentManager(this);
- if (rm.isDoubleBufferingEnabled() && isDoubleBuffered())
+ if (rm.isDoubleBufferingEnabled() && isPaintingDoubleBuffered())
paintDoubleBuffered(r);
else
paintSimple(r);
isRepainting = false;
}
/**
+ * Returns true if we must paint double buffered, that is, when this
+ * component or any of it's ancestors are double buffered.
+ *
+ * @return true if we must paint double buffered, that is, when this
+ * component or any of it's ancestors are double buffered
+ */
+ private boolean isPaintingDoubleBuffered()
+ {
+ boolean doubleBuffered = isDoubleBuffered();
+ Component parent = getParent();
+ while (! doubleBuffered && parent != null)
+ {
+ doubleBuffered = parent instanceof JComponent
+ && ((JComponent) parent).isDoubleBuffered();
+ parent = parent.getParent();
+ }
+ return doubleBuffered;
+ }
+
+ /**
* Performs double buffered repainting.
*/
private void paintDoubleBuffered(Rectangle r)
{
RepaintManager rm = RepaintManager.currentManager(this);
// Paint on the offscreen buffer.
Component root = SwingUtilities.getRoot(this);
Image buffer = rm.getVolatileOffscreenBuffer(this, root.getWidth(),
root.getHeight());
signature.asc
Description: Dies ist ein digital signierter Nachrichtenteil
