I noticed that there are lots of superfluous revalidate and repaint calls in JComponent. I removed these. The reason is that revalidate() may be very expensive, possibly revalidating the whole component tree. This should really only be called if necessary, i.e. if the actual size of a component changes. I also removed the repaint calls. IMO they should be handled (if necessary) by the UI through PropertyChangeEvents.

2005-06-29  Roman Kennke  <[EMAIL PROTECTED]>

       * javax/swing/JComponent.java:
       Removed revalidate and repaint calls in setter methods of various
       properties.

/Roman

Index: javax/swing/JComponent.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/JComponent.java,v
retrieving revision 1.49
diff -u -r1.49 JComponent.java
--- javax/swing/JComponent.java 29 Jun 2005 14:40:50 -0000      1.49
+++ javax/swing/JComponent.java 29 Jun 2005 15:09:41 -0000
@@ -807,8 +807,7 @@
   }
 
   /**
-   * Set the value of the [EMAIL PROTECTED] #border} property, revalidate
-   * and repaint this component.
+   * Set the value of the [EMAIL PROTECTED] #border} property.
    *   
    * @param newBorder The new value of the property
    *
@@ -819,8 +818,6 @@
     Border oldBorder = border;
     border = newBorder;
     firePropertyChange("border", oldBorder, newBorder);
-    revalidate();
-    repaint();
   }
 
   /**
@@ -1989,8 +1986,7 @@
   }
 
   /**
-   * Set the value of the [EMAIL PROTECTED] #enabled} property, revalidate
-   * and repaint this component.
+   * Set the value of the [EMAIL PROTECTED] #enabled} property.
    *
    * @param enable The new value of the property
    */
@@ -1999,52 +1995,40 @@
     boolean oldEnabled = isEnabled();
     super.setEnabled(enable);
     firePropertyChange("enabeld", oldEnabled, enable);
-    revalidate();
-    repaint();
   }
 
   /**
-   * Set the value of the [EMAIL PROTECTED] #font} property, revalidate
-   * and repaint this component.
+   * Set the value of the [EMAIL PROTECTED] #font} property.
    *
    * @param f The new value of the property
    */
   public void setFont(Font f)
   {
     super.setFont(f);
-    revalidate();
-    repaint();
   }
 
   /**
-   * Set the value of the [EMAIL PROTECTED] #background} property, revalidate
-   * and repaint this component.
+   * Set the value of the [EMAIL PROTECTED] #background} property.
    *
    * @param bg The new value of the property
    */
   public void setBackground(Color bg)
   {
     super.setBackground(bg);
-    revalidate();
-    repaint();
   }
 
   /**
-   * Set the value of the [EMAIL PROTECTED] #foreground} property, revalidate
-   * and repaint this component.
+   * Set the value of the [EMAIL PROTECTED] #foreground} property.
    *
    * @param fg The new value of the property
    */
   public void setForeground(Color fg)
   {
     super.setForeground(fg);
-    revalidate();
-    repaint();
   }
 
   /**
-   * Set the value of the [EMAIL PROTECTED] #maximumSize} property, revalidate
-   * and repaint this component.
+   * Set the value of the [EMAIL PROTECTED] #maximumSize} property.
    *
    * @param max The new value of the property
    */
@@ -2053,13 +2037,10 @@
     Dimension oldMaximumSize = maximumSize;
     maximumSize = max;
     firePropertyChange("maximumSize", oldMaximumSize, maximumSize);
-    revalidate();
-    repaint();
   }
 
   /**
-   * Set the value of the [EMAIL PROTECTED] #minimumSize} property, revalidate
-   * and repaint this component.
+   * Set the value of the [EMAIL PROTECTED] #minimumSize} property.
    *
    * @param min The new value of the property
    */
@@ -2068,13 +2049,10 @@
     Dimension oldMinimumSize = minimumSize;
     minimumSize = min;
     firePropertyChange("minimumSize", oldMinimumSize, minimumSize);
-    revalidate();
-    repaint();
   }
 
   /**
-   * Set the value of the [EMAIL PROTECTED] #preferredSize} property, 
revalidate
-   * and repaint this component.
+   * Set the value of the [EMAIL PROTECTED] #preferredSize} property.
    *
    * @param pref The new value of the property
    */
@@ -2140,8 +2118,7 @@
   }
 
   /**
-   * Set the value of the [EMAIL PROTECTED] #opaque} property, revalidate and 
repaint
-   * this component.
+   * Set the value of the [EMAIL PROTECTED] #opaque} property.
    *
    * @param isOpaque The new value of the property
    *
@@ -2155,16 +2132,13 @@
   }
 
   /**
-   * Set the value of the visible property, and revalidate / repaint the
-   * component.
+   * Set the value of the visible property.
    *
    * @param v The new value of the property
    */
   public void setVisible(boolean v)
   {
     super.setVisible(v);
-    revalidate();
-    repaint();
   }
 
   /**
_______________________________________________
Classpath-patches mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/classpath-patches

Reply via email to