This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[GUI] Patch: javax.swing.DefaultButtonModel


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi list,


I just commited the attached patch to cleanup 
javax.swing.DefaultButtonModel a bit.


Michael


2004-06-10  Michael Koch  <konqueror@gmx.de>

	* javax/swing/DefaultButtonModel.java
	(ARMED): Made public final, fixed value.
	(ENABLED): Likewise.
	(PRESSED): Likewise.
	(ROLLOVER): Likewise.
	(SELECTED): Likewise.
	(stateMask): Initialize directly.
	(listenerList): Likewise.
	(mnemonic): Likewise.
	(fireStateChanged): Removed argument, use changeEvent as event.
	All places where this method is called are fixed too.
	(getActionCommant): Fixed javadoc.
	(setGroup): Fixed javadoc.
	(getGroup): New method.


- -- 
Homepage: http://www.worldforge.org/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQFAyADGWSOgCCdjSDsRAr45AJ9lCH7gnLAOrLqBKh6Iv9eWiWK00gCfSjt0
P+KkzTrjvcJAcnOCG3MoyNQ=
=CwYl
-----END PGP SIGNATURE-----
Index: javax/swing/DefaultButtonModel.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/javax/swing/DefaultButtonModel.java,v
retrieving revision 1.5.2.2
diff -u -b -B -r1.5.2.2 DefaultButtonModel.java
--- javax/swing/DefaultButtonModel.java	8 Jun 2004 08:42:53 -0000	1.5.2.2
+++ javax/swing/DefaultButtonModel.java	10 Jun 2004 06:26:18 -0000
@@ -41,6 +41,7 @@
 import java.awt.event.ActionListener;
 import java.awt.event.ItemEvent;
 import java.awt.event.ItemListener;
+import java.awt.event.KeyEvent;
 import java.io.Serializable;
 import java.util.EventListener;
 
@@ -80,37 +81,37 @@
   /** Indicates that the button is <em>partially</em> committed to being
    pressed, but not entirely. This usually happens when a user has pressed
    but not yet released the mouse button. */
-  static int ARMED = 1;
+  public static final int ARMED = 1;
 
   /** State constant indicating that the button is enabled. Buttons cannot
    be pressed or selected unless they are enabled. */
-  static int ENABLED = 2;
+  public static final int ENABLED = 8;
 
   /** State constant indicating that the user is holding down the button.
    When this transitions from true to false, an ActionEvent may be fired,
    depending on the value of the "armed" property.*/
-  static int PRESSED = 4;
+  public static final int PRESSED = 4;
 
   /** State constant indicating that the mouse is currently positioned over
       the button. */
-  static int ROLLOVER = 8;
+  public static final int ROLLOVER = 16;
 
   /** State constant indicating that the button is selected. This constant
       is only meaningful for toggle-type buttons (radio buttons,
       checkboxes). */
-  static int SELECTED = 16;
+  public static final int SELECTED = 2;
 
   /** Represents the "state properties" (armed, enabled, pressed, rollover
       and selected) by a bitwise combination of integer constants. */
-  protected int stateMask;
+  protected int stateMask = ENABLED;
 
   /** List of ItemListeners, ChangeListeners, and ActionListeners
       registered on this model. */
-  protected EventListenerList listenerList;
+  protected EventListenerList listenerList = new EventListenerList();;
 
   /** The single ChangeEvent this model (re)uses to call its
       ChangeListeners. */
-  protected ChangeEvent changeEvent;
+  protected ChangeEvent changeEvent = new ChangeEvent(this);
 
   /** The group this model belongs to. Only one button in a group may be
       selected at any given time. */
@@ -118,7 +119,7 @@
   
   /** The key code (one of {@link java.awt.event.KeyEvent} VK_*) used to
       press this button via a keyboard interface. */
-  protected int mnemonic;
+  protected int mnemonic = KeyEvent.VK_UNDEFINED;
 
   /** The string used as the "command" property of any ActionEvent this
       model sends. */
@@ -126,10 +127,6 @@
 
   public DefaultButtonModel()
   {
-    stateMask = ENABLED;
-    mnemonic = java.awt.event.KeyEvent.VK_UNDEFINED;
-    listenerList = new EventListenerList();    
-    changeEvent = new ChangeEvent(this);
   }
 
   /**
@@ -289,12 +286,12 @@
    *
    * @param event The ChangeEvent to fire
    */
-  public void fireStateChanged(ChangeEvent e)
+  public void fireStateChanged()
   {
     ChangeListener[] ll = getChangeListeners();
     
     for (int i = 0; i < ll.length; i++)
-      ll[i].stateChanged(e);
+      ll[i].stateChanged(changeEvent);
   }
 
   /**
@@ -321,7 +318,7 @@
 
     stateMask = newstate;
 
-    fireStateChanged(changeEvent);
+    fireStateChanged();
 
     if ((oldstate & SELECTED) == 0
         && (newstate & SELECTED) == SELECTED)
@@ -463,7 +460,7 @@
     if (mnemonic != key)
       {
         mnemonic = key;
-        fireStateChanged(changeEvent);
+        fireStateChanged();
       }
   }
   
@@ -479,14 +476,12 @@
     if (actionCommand != s)
       {
         actionCommand = s;
-        fireStateChanged(changeEvent);
+        fireStateChanged();
       }
   } 
   
   /**
-   * Set the value of the model's "actionCommand" property. This property
-   * is used as the "command" property of the {@link ActionEvent} fired
-   * from the model.
+   * Returns the current value of the model's "actionCommand" property.
    *
    * @return The current "actionCommand" property
    */
@@ -498,7 +493,7 @@
   /**
    * Set the value of the model's "group" property. The model is said to be
    * a member of the {@link ButtonGroup} held in its "group" property, and
-   * only one models in a given group can have their "selected" property be
+   * only one model in a given group can have their "selected" property be
    * <code>true</code> at a time.
    *
    * @param g The new "group" property
@@ -508,7 +503,17 @@
     if (group != g)
       {
         group = g;
-        fireStateChanged(changeEvent);
+        fireStateChanged();
       }
   }
+
+  /**
+   * Returns the current value of the model's "group" property.
+   *
+   * @return The value of the "group" property
+   */
+  public ButtonGroup getGroup()
+  {
+    return group;
+  }
 }

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]