uk.ac.starlink.util.gui
Class ChangingComboBoxModel

java.lang.Object
  extended by javax.swing.AbstractListModel
      extended by javax.swing.DefaultComboBoxModel
          extended by uk.ac.starlink.util.gui.ChangingComboBoxModel
All Implemented Interfaces:
Serializable, ComboBoxModel, ListModel, MutableComboBoxModel

public class ChangingComboBoxModel
extends DefaultComboBoxModel

ComboBoxModel which can notify ChangeListeners and ActionListeners of changes in the selection.

Since:
6 Jun 2007
Author:
Mark Taylor
See Also:
Serialized Form

Field Summary
 
Fields inherited from class javax.swing.AbstractListModel
listenerList
 
Constructor Summary
ChangingComboBoxModel()
          Constructs an empty model.
ChangingComboBoxModel(Object[] items)
          Constructs a model with a given initial list of items.
 
Method Summary
 void addActionListener(ActionListener listener)
          Adds a listener which is notified whenever the selection changes.
 void addChangeListener(ChangeListener listener)
          Adds a listener which is notified whenever the selection changes.
protected  void fireActionPerformed(Object source)
          Called to notify listeners of a change.
protected  void fireSelectionChanged(Object source)
          Called to notify listeners of a change.
 void removeActionListener(ActionListener listener)
          Removes a listener previously added by #addListener.
 void removeChangeListener(ChangeListener listener)
          Removes a listener previously added by #addListener.
 void setSelectedItem(Object item)
           
 
Methods inherited from class javax.swing.DefaultComboBoxModel
addElement, getElementAt, getIndexOf, getSelectedItem, getSize, insertElementAt, removeAllElements, removeElement, removeElementAt
 
Methods inherited from class javax.swing.AbstractListModel
addListDataListener, fireContentsChanged, fireIntervalAdded, fireIntervalRemoved, getListDataListeners, getListeners, removeListDataListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.swing.ListModel
addListDataListener, removeListDataListener
 

Constructor Detail

ChangingComboBoxModel

public ChangingComboBoxModel()
Constructs an empty model.


ChangingComboBoxModel

public ChangingComboBoxModel(Object[] 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(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 #addListener.

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 #addListener.

Parameters:
listener - listener to remove

setSelectedItem

public void setSelectedItem(Object item)
Specified by:
setSelectedItem in interface ComboBoxModel
Overrides:
setSelectedItem in class DefaultComboBoxModel

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


Copyright © 2015 Central Laboratory of the Research Councils. All Rights Reserved.