Hi,

I committed this patch to fix a DefaultComboBoxModel problem exposed by a bug in the JBoss installer. I'll commit a corresponding Mauve test shortly.

Tom

2006-10-13  Thomas Fitzsimmons  <[EMAIL PROTECTED]>

        * javax/swing/DefaultComboBoxModel.java (setSelectedItem):
          Simply return if object is not in the list.
Index: javax/swing/DefaultComboBoxModel.java
===================================================================
RCS file: /sources/classpath/classpath/javax/swing/DefaultComboBoxModel.java,v
retrieving revision 1.16
diff -u -r1.16 DefaultComboBoxModel.java
--- javax/swing/DefaultComboBoxModel.java	16 Jun 2006 14:15:41 -0000	1.16
+++ javax/swing/DefaultComboBoxModel.java	13 Oct 2006 04:21:08 -0000
@@ -224,18 +224,26 @@
    */
   public void setSelectedItem(Object object)
   {
-    if (selectedItem == null)
-      {
-        if (object == null)
-          return;
-      }
-    else
-      {
-        if (selectedItem.equals(object))
-          return;
-      }
+    // No item is selected and object is null, so no change required.
+    if (selectedItem == null && object == null)
+      return;
+
+    // object is already selected so no change required.
+    if (selectedItem != null && selectedItem.equals(object))
+      return;
+
+    // Simply return if object is not in the list.
+    if (object != null && getIndexOf(object) == -1)
+      return;
+
+    // Here we know that object is either an item in the list or null.
+
+    // Handle the three change cases: selectedItem is null, object is
+    // non-null; selectedItem is non-null, object is null;
+    // selectedItem is non-null, object is non-null and they're not
+    // equal.
     selectedItem = object;
-    fireContentsChanged(this, -1, -1);    
+    fireContentsChanged(this, -1, -1);
   }
 
   /**

Reply via email to