Package uk.ac.starlink.util.gui
Class ChangingComboBoxModel<E>
- java.lang.Object
-
- javax.swing.AbstractListModel<E>
-
- javax.swing.DefaultComboBoxModel<E>
-
- uk.ac.starlink.util.gui.ChangingComboBoxModel<E>
-
- All Implemented Interfaces:
java.io.Serializable,javax.swing.ComboBoxModel<E>,javax.swing.ListModel<E>,javax.swing.MutableComboBoxModel<E>
public class ChangingComboBoxModel<E> extends javax.swing.DefaultComboBoxModel<E>ComboBoxModel which can notifyChangeListeners andActionListeners of changes in the selection.- Since:
- 6 Jun 2007
- Author:
- Mark Taylor
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description ChangingComboBoxModel()Constructs an empty model.ChangingComboBoxModel(E[] items)Constructs a model with a given initial array of items.ChangingComboBoxModel(java.util.Collection<E> items)Constructs a model with a given initial list of items.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddActionListener(java.awt.event.ActionListener listener)Adds a listener which is notified whenever the selection changes.voidaddChangeListener(javax.swing.event.ChangeListener listener)Adds a listener which is notified whenever the selection changes.protected voidfireActionPerformed(java.lang.Object source)Called to notify listeners of a change.protected voidfireSelectionChanged(java.lang.Object source)Called to notify listeners of a change.voidremoveActionListener(java.awt.event.ActionListener listener)Removes a listener previously added byaddActionListener(java.awt.event.ActionListener).voidremoveChangeListener(javax.swing.event.ChangeListener listener)Removes a listener previously added byaddChangeListener(javax.swing.event.ChangeListener).voidsetSelectedItem(java.lang.Object item)-
Methods inherited from class javax.swing.DefaultComboBoxModel
addAll, addAll, addElement, getElementAt, getIndexOf, getSelectedItem, getSize, insertElementAt, removeAllElements, removeElement, removeElementAt
-
Methods inherited from class javax.swing.AbstractListModel
addListDataListener, fireContentsChanged, fireIntervalAdded, fireIntervalRemoved, getListDataListeners, getListeners, removeListDataListener
-
-
-
-
Constructor Detail
-
ChangingComboBoxModel
public ChangingComboBoxModel()
Constructs an empty model.
-
ChangingComboBoxModel
public ChangingComboBoxModel(E[] items)
Constructs a model with a given initial array of items.- Parameters:
items- initial list of items in the model
-
ChangingComboBoxModel
public ChangingComboBoxModel(java.util.Collection<E> items)
Constructs a model with a given initial list of items.- Parameters:
items- initial list of items in the model
-
-
Method Detail
-
addChangeListener
public void addChangeListener(javax.swing.event.ChangeListener listener)
Adds a listener which is notified whenever the selection changes.- Parameters:
listener- listener to add
-
removeChangeListener
public void removeChangeListener(javax.swing.event.ChangeListener listener)
Removes a listener previously added byaddChangeListener(javax.swing.event.ChangeListener).- Parameters:
listener- listener to remove
-
addActionListener
public void addActionListener(java.awt.event.ActionListener listener)
Adds a listener which is notified whenever the selection changes.- Parameters:
listener- listener to add
-
removeActionListener
public void removeActionListener(java.awt.event.ActionListener listener)
Removes a listener previously added byaddActionListener(java.awt.event.ActionListener).- Parameters:
listener- listener to remove
-
setSelectedItem
public void setSelectedItem(java.lang.Object item)
-
fireSelectionChanged
protected void fireSelectionChanged(java.lang.Object source)
Called to notify listeners of a change.- Parameters:
source- change source
-
fireActionPerformed
protected void fireActionPerformed(java.lang.Object source)
Called to notify listeners of a change.- Parameters:
source- change source
-
-