Package org.jdesktop.swingx.combobox
Class ListComboBoxModel<E>
java.lang.Object
javax.swing.AbstractListModel<E>
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<E>
,ListModel<E>
- Direct Known Subclasses:
EnumComboBoxModel
,MapComboBoxModel
public class ListComboBoxModel<E>
extends AbstractListModel<E>
implements ComboBoxModel<E>, ActionListener
A
ComboBoxModel
for List
s.- Author:
- jm158417, Karl George Schaefer
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionA reference to the list backing this model.protected E
The currently selected item.static final String
A key used to notify the model that the backingList
has changed.Fields inherited from class javax.swing.AbstractListModel
listenerList
-
Constructor Summary
ConstructorsConstructorDescriptionListComboBoxModel
(List<E> list) Creates aListComboBoxModel
backed by the suppliedlist
. -
Method Summary
Modifier and TypeMethodDescriptionvoid
getElementAt
(int index) int
getSize()
void
setSelectedItem
(Object item) Set the selected item.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
-
Field Details
-
UPDATE
A key used to notify the model that the backingList
has changed.- See Also:
-
data
A reference to the list backing this model.This model does not make a copy of the list, so any changes in the list without synchronizing the model may have drastic effects.
-
selected
The currently selected item.
-
-
Constructor Details
-
ListComboBoxModel
Creates aListComboBoxModel
backed by the suppliedlist
.- Parameters:
list
- the list backing this model- Throws:
NullPointerException
- iflist
isnull
-
-
Method Details
-
setSelectedItem
Set the selected item. The implementation of this method should notify all registeredListDataListener
s that the contents have changed.- Specified by:
setSelectedItem
in interfaceComboBoxModel<E>
- Parameters:
item
- the list object to select ornull
to clear the selection- Throws:
ClassCastException
- ifitem
is not of typeE
-
getSelectedItem
- Specified by:
getSelectedItem
in interfaceComboBoxModel<E>
-
getElementAt
- Specified by:
getElementAt
in interfaceListModel<E>
-
getSize
public int getSize() -
actionPerformed
- Specified by:
actionPerformed
in interfaceActionListener
-