My recent patch to ComponentUI.update() revealed some other problems.
Obviously, the clipping in components that use renderers (lists,
tables,...) was broken and didn't play nice with my adjustments. This
is fixed now.

2005-10-12  Roman Kennke  <[EMAIL PROTECTED]>

        * javax/swing/CellRendererPane.java
        (paintComponent): Fix clipping of cells.
        * javax/swing/plaf/basic/BasicTableUI.java
        (paint): Fix clipping of cells.

/Roman
Index: javax/swing/CellRendererPane.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/CellRendererPane.java,v
retrieving revision 1.10
diff -u -r1.10 CellRendererPane.java
--- javax/swing/CellRendererPane.java	26 Jul 2005 15:30:54 -0000	1.10
+++ javax/swing/CellRendererPane.java	12 Oct 2005 19:33:21 -0000
@@ -175,9 +175,10 @@
     // reparent c
     addImpl(c, null, 0);
 
+    Rectangle oldClip = graphics.getClipBounds();
     // translate to (x,y)
     graphics.translate(x, y);
-
+    graphics.clipRect(0, 0, w, h);
     // set bounds of c
     c.setBounds(0, 0, w, h);
 
@@ -192,7 +193,7 @@
 
     // untranslate g
     graphics.translate(-x, -y);
-
+    graphics.setClip(oldClip);
   } // paintComponent()
 
   /**
Index: javax/swing/plaf/basic/BasicTableUI.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/basic/BasicTableUI.java,v
retrieving revision 1.29
diff -u -r1.29 BasicTableUI.java
--- javax/swing/plaf/basic/BasicTableUI.java	12 Oct 2005 12:10:00 -0000	1.29
+++ javax/swing/plaf/basic/BasicTableUI.java	12 Oct 2005 19:33:22 -0000
@@ -1065,9 +1065,12 @@
             Rectangle bounds = new Rectangle(x, y, width, height);
               if (bounds.intersects(clip))
               {
+                // FIXME: Handle cell painting via CellRendererPane!
                 TableCellRenderer rend = table.getCellRenderer(r, c);
                 Component comp = table.prepareRenderer(rend, r, c);
+                Rectangle oldClip = gfx.getClipBounds();
                 gfx.translate(x, y);
+                gfx.setClip(0, 0, width, height);
                 comp.setBounds(new Rectangle(0, 0, width, height));
                 // Set correct border on cell renderer.
                 // Only the lead selection cell gets a border
@@ -1084,6 +1087,7 @@
                 if (comp instanceof JTextField)
                   ((JTextField)comp).getCaret().paint(gfx);
                 gfx.translate(-x, -y);
+                gfx.setClip(oldClip);
               }
               y += height;
           }
_______________________________________________
Classpath-patches mailing list
Classpath-patches@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath-patches

Reply via email to