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] Fix Button naming


Hi,

I committed this patch to java-gui-branch.  It gives each button object
a unique name, as returned by Component.getName.

Tom

2004-06-14  Thomas Fitzsimmons  <fitzsim@redhat.com>

	* java/awt/Button.java (next_button_number): New field.
	(paramString): Change output.
	(generateName): New method.
	(getUniqueLong): New method.

Index: java/awt/Button.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/awt/Button.java,v
retrieving revision 1.12
diff -u -r1.12 Button.java
--- java/awt/Button.java	10 Feb 2004 18:57:22 -0000	1.12
+++ java/awt/Button.java	15 Jun 2004 01:36:33 -0000
@@ -81,6 +81,11 @@
 // List of ActionListeners for this class.
 private transient ActionListener action_listeners;
 
+  /*
+   * The number used to generate the name returned by getName.
+   */
+  private static transient long next_button_number = 0;
+
 /*************************************************************************/
 
 /*
@@ -305,9 +310,24 @@
 protected String
 paramString()
 {
-  return ("label=" + getLabel() + ",actionCommand=" + getActionCommand()
-	  + "," + super.paramString());
+  return getName () + "," + getX () + "," + getY () + ","
+    + getWidth () + "x" + getHeight () + ",label=" + getLabel ();
 }
 
+  /**
+   * Generate a unique name for this button.
+   *
+   * @return A unique name for this button.
+   */
+  String generateName ()
+  {
+    return "button" + getUniqueLong ();
+  }
+
+  private static synchronized long getUniqueLong ()
+  {
+    return next_button_number++;
+  }
+
 } // class Button 
 

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