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>

public class ChangingComboBoxModel<E> extends DefaultComboBoxModel<E>
ComboBoxModel which can notify ChangeListeners and ActionListeners of changes in the selection.
Since:
6 Jun 2007
Author:
Mark Taylor
See Also:
  • Constructor Details

    • 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(Collection<E> items)
      Constructs a model with a given initial list of items.
      Parameters:
      items - initial list of items in the model
  • Method Details

    • addChangeListener

      public void addChangeListener(ChangeListener listener)
      Adds a listener which is notified whenever the selection changes.
      Parameters:
      listener - listener to add
    • removeChangeListener

      public void removeChangeListener(ChangeListener listener)
      Removes a listener previously added by addChangeListener(javax.swing.event.ChangeListener).
      Parameters:
      listener - listener to remove
    • addActionListener

      public void addActionListener(ActionListener listener)
      Adds a listener which is notified whenever the selection changes.
      Parameters:
      listener - listener to add
    • removeActionListener

      public void removeActionListener(ActionListener listener)
      Removes a listener previously added by addActionListener(java.awt.event.ActionListener).
      Parameters:
      listener - listener to remove
    • setSelectedItem

      public void setSelectedItem(Object item)
      Specified by:
      setSelectedItem in interface ComboBoxModel<E>
      Overrides:
      setSelectedItem in class DefaultComboBoxModel<E>
    • fireSelectionChanged

      protected void fireSelectionChanged(Object source)
      Called to notify listeners of a change.
      Parameters:
      source - change source
    • fireActionPerformed

      protected void fireActionPerformed(Object source)
      Called to notify listeners of a change.
      Parameters:
      source - change source