This prevents setEnabled() from getting active, if the actual value does
not change.

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

        * javax/swing/AbstractButton.java
        Filled empty blocks with comments.
        (ButtonChangeListener.stateChanged): Moved implementation from
        inner class in createChangeListener to this protected class.
        (setEnabled): Do nothing if actual state does not change.
        (createChangeListener): Return instance of ButtonChangeListener
        here.

/Roman
Index: javax/swing/AbstractButton.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/AbstractButton.java,v
retrieving revision 1.47
diff -u -r1.47 AbstractButton.java
--- javax/swing/AbstractButton.java	12 Oct 2005 13:27:32 -0000	1.47
+++ javax/swing/AbstractButton.java	18 Oct 2005 13:35:55 -0000
@@ -165,6 +165,8 @@
      */
     public void stateChanged(ChangeEvent ev)
     {
+      AbstractButton.this.fireStateChanged();
+      repaint();
     }
   }
 
@@ -375,6 +377,7 @@
     
     protected AccessibleAbstractButton()
     {
+      // Nothing to do here yet.
     }
 
     public AccessibleStateSet getAccessibleStateSet()
@@ -519,7 +522,7 @@
    * The [EMAIL PROTECTED] #init(String, Icon)} method is not called automatically by this
    * constructor.
    *
-   * @see [EMAIL PROTECTED] #init(String, Icon)}
+   * @see #init(String, Icon)
    */
   public AbstractButton()
   {
@@ -949,6 +952,9 @@
    */
   public void setEnabled(boolean b)
   {
+    // Do nothing if state does not change.
+    if (b == isEnabled())
+      return;
     super.setEnabled(b);
     ButtonModel mod = getModel();
     if (mod != null)
@@ -1630,16 +1636,9 @@
    *
    * @return The new ChangeListener
    */
-  protected  ChangeListener createChangeListener()
+  protected ChangeListener createChangeListener()
   {
-    return new ChangeListener()
-      {
-        public void stateChanged(ChangeEvent e)
-        {
-          AbstractButton.this.fireStateChanged();
-          AbstractButton.this.repaint();          
-        }
-      };
+    return new ButtonChangeListener();
   }
 
   /**
@@ -2005,6 +2004,7 @@
    */
   public void updateUI()
   {
+    // TODO: What to do here?
   }
 
   /**
_______________________________________________
Classpath-patches mailing list
Classpath-patches@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath-patches

Reply via email to