Class ListComboBoxModel<E>
java.lang.Object
javax.swing.AbstractListModel
org.jdesktop.swingx.combobox.ListComboBoxModel<E>
- Type Parameters:
E- the type of elements maintained by the list backing this model
- All Implemented Interfaces:
ActionListener, Serializable, EventListener, ComboBoxModel, ListModel
- Direct Known Subclasses:
EnumComboBoxModel, MapComboBoxModel
public class ListComboBoxModel<E>
extends AbstractListModel
implements ComboBoxModel, ActionListener
A
ComboBoxModel for Lists.- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionA reference to the list backing this model.protected EThe currently selected item.static final StringA key used to notify the model that the backingListhas changed.Fields inherited from class AbstractListModel
listenerList -
Constructor Summary
ConstructorsConstructorDescriptionListComboBoxModel(List<E> list) Creates aListComboBoxModelbacked by the suppliedlist. -
Method Summary
Modifier and TypeMethodDescriptionvoidgetElementAt(int index) intgetSize()voidsetSelectedItem(Object item) Set the selected item.Methods 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
-
Field Details
-
UPDATE
A key used to notify the model that the backingListhas changed.- See Also:
-
data
-
selected
The currently selected item.
-
-
Constructor Details
-
ListComboBoxModel
Creates aListComboBoxModelbacked by the suppliedlist.- Parameters:
list- the list backing this model- Throws:
NullPointerException- iflistisnull
-
-
Method Details
-
setSelectedItem
Set the selected item. The implementation of this method should notify all registeredListDataListeners that the contents have changed.- Specified by:
setSelectedItemin interfaceComboBoxModel<E>- Parameters:
item- the list object to select ornullto clear the selection- Throws:
ClassCastException- ifitemis not of typeE
-
getSelectedItem
- Specified by:
getSelectedItemin interfaceComboBoxModel<E>
-
getElementAt
- Specified by:
getElementAtin interfaceListModel<E>
-
getSize
-
actionPerformed
- Specified by:
actionPerformedin interfaceActionListener
-