classpath-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[cp-patches] FYI: DefaultComboBoxModel.setSelectedItem()


From: David Gilbert
Subject: [cp-patches] FYI: DefaultComboBoxModel.setSelectedItem()
Date: Tue, 11 Oct 2005 21:46:53 +0000
User-agent: Mozilla Thunderbird 1.0.6 (X11/20050728)

I committed this patch to fix a bug in the setSelectedItem() method. There were two problems, first the method wouldn't allow the selected item to be a non-null object that isn't in the list (this is valid), and second the method was firing change events in cases where the selected item value isn't changed.

2005-10-11  David Gilbert  <address@hidden>

        * javax/swing/DefaultComboBoxModel.java
        (setSelectedItem): allow values not in list, and don't fire an event
        if the value is unchanged.

The corresponding Mauve test has been updated to cover this patch.

Regards,

Dave
Index: javax/swing/DefaultComboBoxModel.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/DefaultComboBoxModel.java,v
retrieving revision 1.13
diff -u -r1.13 DefaultComboBoxModel.java
--- javax/swing/DefaultComboBoxModel.java       24 Sep 2005 20:24:38 -0000      
1.13
+++ javax/swing/DefaultComboBoxModel.java       11 Oct 2005 20:39:17 -0000
@@ -222,9 +222,18 @@
    */
   public void setSelectedItem(Object object)
   {
+    if (selectedItem == null)
+      {
+        if (object == null)
+          return;
+      }
+    else
+      {
+        if (selectedItem.equals(object))
+          return;
+      }
     selectedItem = object;
-    if(object == null || list.contains(object)) 
-      fireContentsChanged(this, -1, -1);       
+    fireContentsChanged(this, -1, -1);    
   }
 
   /**

reply via email to

[Prev in Thread] Current Thread [Next in Thread]