diff options
author | David Gilbert <david.gilbert@object-refinery.com> | 2005-09-24 20:24:37 +0000 |
---|---|---|
committer | David Gilbert <david.gilbert@object-refinery.com> | 2005-09-24 20:24:37 +0000 |
commit | bb662f139686d65dc7daef92e8b66bc96c7198db (patch) | |
tree | 962fc5849d0480ac8aab81b1e6ccf55bfd4f3f37 /javax/swing/DefaultComboBoxModel.java | |
parent | 6d26d4d6ceca7011ce2473e8acc19f1ea56d22c2 (diff) | |
download | classpath-bb662f139686d65dc7daef92e8b66bc96c7198db.tar.gz |
2005-09-24 David Gilbert <david.gilbert@object-refinery.com>
* javax/swing/DefaultComboBoxModel.java
(addElement): always fire event for interval added, and call
setSelectedItem() if this is the first item.
----------------------------------------------------------------------
Diffstat (limited to 'javax/swing/DefaultComboBoxModel.java')
-rw-r--r-- | javax/swing/DefaultComboBoxModel.java | 19 |
1 files changed, 6 insertions, 13 deletions
diff --git a/javax/swing/DefaultComboBoxModel.java b/javax/swing/DefaultComboBoxModel.java index 1456f21fa..c564cf720 100644 --- a/javax/swing/DefaultComboBoxModel.java +++ b/javax/swing/DefaultComboBoxModel.java @@ -113,24 +113,17 @@ public class DefaultComboBoxModel extends AbstractListModel /** * Adds an element to the model's item list and sends a {@link ListDataEvent} - * to all registered listeners. If the item list is empty, the new element - * also becomes the model's selected item. + * to all registered listeners. If the new element is the first item added + * to the list, it is set as the selected item. * * @param object item to add to the model's item list. */ public void addElement(Object object) { - if (list.size() == 0) - { - list.add(object); - selectedItem = object; - fireContentsChanged(this, -1, -1); - } - else - { - list.add(object); - fireIntervalAdded(this, list.size() - 1, list.size() - 1); - } + list.add(object); + fireIntervalAdded(this, list.size() - 1, list.size() - 1); + if (list.size() == 1) + setSelectedItem(object); } /** |