Class ChangingComboBoxModel<E>
java.lang.Object
javax.swing.AbstractListModel<E>
javax.swing.DefaultComboBoxModel<E>
uk.ac.starlink.util.gui.ChangingComboBoxModel<E>
- All Implemented Interfaces:
Serializable, ComboBoxModel<E>, ListModel<E>, MutableComboBoxModel<E>
ComboBoxModel which can notify
ChangeListeners
and ActionListeners of changes in the selection.- Since:
- 6 Jun 2007
- Author:
- Mark Taylor
- See Also:
-
Field Summary
Fields inherited from class AbstractListModel
listenerList -
Constructor Summary
ConstructorsConstructorDescriptionConstructs an empty model.ChangingComboBoxModel(E[] items) Constructs a model with a given initial array of items.ChangingComboBoxModel(Collection<E> items) Constructs a model with a given initial list of items. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddActionListener(ActionListener listener) Adds a listener which is notified whenever the selection changes.voidaddChangeListener(ChangeListener listener) Adds a listener which is notified whenever the selection changes.protected voidfireActionPerformed(Object source) Called to notify listeners of a change.protected voidfireSelectionChanged(Object source) Called to notify listeners of a change.voidremoveActionListener(ActionListener listener) Removes a listener previously added byaddActionListener(ActionListener).voidremoveChangeListener(ChangeListener listener) Removes a listener previously added byaddChangeListener(ChangeListener).voidsetSelectedItem(Object item) Methods inherited from class DefaultComboBoxModel
addAll, addAll, addElement, getElementAt, getIndexOf, getSelectedItem, getSize, insertElementAt, removeAllElements, removeElement, removeElementAtMethods inherited from class AbstractListModel
addListDataListener, fireContentsChanged, fireIntervalAdded, fireIntervalRemoved, getListDataListeners, getListeners, removeListDataListenerMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ListModel
addListDataListener, removeListDataListener
-
Constructor Details
-
ChangingComboBoxModel
public ChangingComboBoxModel()Constructs an empty model. -
ChangingComboBoxModel
Constructs a model with a given initial array of items.- Parameters:
items- initial list of items in the model
-
ChangingComboBoxModel
Constructs a model with a given initial list of items.- Parameters:
items- initial list of items in the model
-
-
Method Details
-
addChangeListener
Adds a listener which is notified whenever the selection changes.- Parameters:
listener- listener to add
-
removeChangeListener
Removes a listener previously added byaddChangeListener(ChangeListener).- Parameters:
listener- listener to remove
-
addActionListener
Adds a listener which is notified whenever the selection changes.- Parameters:
listener- listener to add
-
removeActionListener
Removes a listener previously added byaddActionListener(ActionListener).- Parameters:
listener- listener to remove
-
setSelectedItem
- Specified by:
setSelectedItemin interfaceComboBoxModel<E>- Overrides:
setSelectedItemin classDefaultComboBoxModel<E>
-
fireSelectionChanged
Called to notify listeners of a change.- Parameters:
source- change source
-
fireActionPerformed
Called to notify listeners of a change.- Parameters:
source- change source
-