This fixes a small but annoying painting issue that happens if some
components are invisible. Also, I removed some useless 'optimization'
from repaint() that caused unnecessary creation of Rectangle objects.

2006-02-15  Roman Kennke  <[EMAIL PROTECTED]>

        * javax/swing/JComponent.java
        (paintChildren): Also check for the visibility of a child
component
        to avoid artifacts.
        (repaint): Simply add this component to the RepaintManager rather
than
        trying to do useless optimization here.

/Roman
Index: javax/swing/JComponent.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/JComponent.java,v
retrieving revision 1.100
diff -u -r1.100 JComponent.java
--- javax/swing/JComponent.java	14 Feb 2006 15:23:27 -0000	1.100
+++ javax/swing/JComponent.java	15 Feb 2006 17:17:13 -0000
@@ -1619,11 +1619,10 @@
     // optimizedDrawingEnabled (== it tiles its children).
     if (! isOptimizedDrawingEnabled())
       {
-        Rectangle clip = g.getClipBounds();
         for (int i = 0; i < children.length; i++)
           {
             Rectangle childBounds = children[i].getBounds();
-            if (children[i].isOpaque()
+            if (children[i].isOpaque() && children[i].isVisible()
                 && SwingUtilities.isRectangleContainingRectangle(childBounds,
                                                             g.getClipBounds()))
               {
@@ -2206,12 +2205,8 @@
    */
   public void repaint(long tm, int x, int y, int width, int height)
   {
-    Rectangle dirty = new Rectangle(x, y, width, height);
-    Rectangle vis = getVisibleRect();
-    dirty = dirty.intersection(vis);
-    RepaintManager.currentManager(this).addDirtyRegion(this, dirty.x, dirty.y,
-                                                       dirty.width,
-                                                       dirty.height);
+    RepaintManager.currentManager(this).addDirtyRegion(this, x, y, width,
+                                                       height);
   }
 
   /**
@@ -2223,8 +2218,7 @@
    */
   public void repaint(Rectangle r)
   {
-    repaint((long) 0, (int) r.getX(), (int) r.getY(), (int) r.getWidth(),
-            (int) r.getHeight());
+    repaint(0, r.x, r.y, r.width, r.height);
   }
 
   /**

Reply via email to