Trying to understand, why our internal frames are resized slowly, I
concluded, that the frame of the same size is repainted nine times
during resizing, when only one is needed. The reason is that the repaint
manager treats the repaint rectangles as different if the repaint was
called on the different components. In reality, the child and parent
rectangles are the same, and just coordinates must be translated.
The patch forces to travel till the last lightweight parent and add its
region as dirty, rather than adding as dirty the region of the current
component. This noticeably increases the speed of resizing (that is more
visible with the complex windows like JTable).
2006-05-15 Audrius Meskauskas <[EMAIL PROTECTED]>
* javax/swing/RepaintManager.java (addDirtyRegion):
If there is a lightweight parent, recursively add the corresponding
region of the parent instead.
Index: RepaintManager.java
===================================================================
RCS file: /sources/classpath/classpath/javax/swing/RepaintManager.java,v
retrieving revision 1.31
diff -u -r1.31 RepaintManager.java
--- RepaintManager.java 3 May 2006 14:29:45 -0000 1.31
+++ RepaintManager.java 15 May 2006 09:42:22 -0000
@@ -422,6 +422,16 @@
{
if (w <= 0 || h <= 0 || !component.isShowing())
return;
+
+ Component parent = component.getParent();
+ if (parent instanceof JComponent)
+ {
+ // If there is a delegateable parent, add the parent region instead.
+ addDirtyRegion((JComponent) parent, x + component.getX(),
+ y + component.getY(), w, h);
+ return;
+ }
+
component.computeVisibleRect(rectCache);
SwingUtilities.computeIntersection(x, y, w, h, rectCache);