classpath-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[cp-patches] FYI: Removed revalidate and repaint calls in JComponent


From: Roman Kennke
Subject: [cp-patches] FYI: Removed revalidate and repaint calls in JComponent
Date: Wed, 29 Jun 2005 17:12:44 +0200
User-agent: Mozilla Thunderbird 1.0.2 (X11/20050317)

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  <address@hidden>

       * 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 address@hidden #border} property, revalidate
-   * and repaint this component.
+   * Set the value of the address@hidden #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 address@hidden #enabled} property, revalidate
-   * and repaint this component.
+   * Set the value of the address@hidden #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 address@hidden #font} property, revalidate
-   * and repaint this component.
+   * Set the value of the address@hidden #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 address@hidden #background} property, revalidate
-   * and repaint this component.
+   * Set the value of the address@hidden #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 address@hidden #foreground} property, revalidate
-   * and repaint this component.
+   * Set the value of the address@hidden #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 address@hidden #maximumSize} property, revalidate
-   * and repaint this component.
+   * Set the value of the address@hidden #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 address@hidden #minimumSize} property, revalidate
-   * and repaint this component.
+   * Set the value of the address@hidden #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 address@hidden #preferredSize} property, revalidate
-   * and repaint this component.
+   * Set the value of the address@hidden #preferredSize} property.
    *
    * @param pref The new value of the property
    */
@@ -2140,8 +2118,7 @@
   }
 
   /**
-   * Set the value of the address@hidden #opaque} property, revalidate and 
repaint
-   * this component.
+   * Set the value of the address@hidden #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();
   }
 
   /**

reply via email to

[Prev in Thread] Current Thread [Next in Thread]