[cp-patches] FYI: JLabel.setDisplayedMnemonic() - another fixlet

David Gilbert david.gilbert at object-refinery.com
Thu Jun 22 09:49:17 UTC 2006


This patch (committed) fixes a couple of failing Mauve tests (which I'll commit 
shortly):

2006-06-22  David Gilbert  <david.gilbert at object-refinery.com>

	* javax/swing/JLabel.java
	(setDisplayedMnemonic(int)): Fire property change event AFTER updating
	field,
	(setDisplayedMnemonicIndex): Modified argument checking to handle case
	where label text is null.

Regards,

Dave
-------------- next part --------------
Index: javax/swing/JLabel.java
===================================================================
RCS file: /sources/classpath/classpath/javax/swing/JLabel.java,v
retrieving revision 1.37
diff -u -r1.37 JLabel.java
--- javax/swing/JLabel.java	22 Jun 2006 09:04:15 -0000	1.37
+++ javax/swing/JLabel.java	22 Jun 2006 09:42:50 -0000
@@ -622,9 +622,9 @@
   {
     if (displayedMnemonic != mnemonic)
       {
-        firePropertyChange("displayedMnemonic", displayedMnemonic, mnemonic);
+        int old = displayedMnemonic;
         displayedMnemonic = mnemonic;
-
+        firePropertyChange("displayedMnemonic", old, displayedMnemonic);
         if (text != null)
           setDisplayedMnemonicIndex(text.toUpperCase().indexOf(mnemonic));
       }
@@ -677,7 +677,10 @@
   public void setDisplayedMnemonicIndex(int newIndex)
     throws IllegalArgumentException
   {
-    if (newIndex < -1 || (text != null && newIndex >= text.length()))
+    int maxValid = -1;
+    if (text != null)
+      maxValid = text.length() - 1;
+    if (newIndex < -1 || newIndex > maxValid)
       throw new IllegalArgumentException();
 
     if (newIndex != displayedMnemonicIndex)


More information about the Classpath-patches mailing list