Package org.jdesktop.swingx.combobox
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:
java.awt.event.ActionListener
,java.io.Serializable
,java.util.EventListener
,javax.swing.ComboBoxModel
,javax.swing.ListModel
- Direct Known Subclasses:
EnumComboBoxModel
,MapComboBoxModel
public class ListComboBoxModel<E> extends javax.swing.AbstractListModel implements javax.swing.ComboBoxModel, java.awt.event.ActionListener
AComboBoxModel
forList
s.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description ListComboBoxModel(java.util.List<E> list)
Creates aListComboBoxModel
backed by the suppliedlist
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
actionPerformed(java.awt.event.ActionEvent evt)
E
getElementAt(int index)
E
getSelectedItem()
int
getSize()
void
setSelectedItem(java.lang.Object item)
Set the selected item.-
Methods inherited from class javax.swing.AbstractListModel
addListDataListener, fireContentsChanged, fireIntervalAdded, fireIntervalRemoved, getListDataListeners, getListeners, removeListDataListener
-
-
-
-
Field Detail
-
UPDATE
public static final java.lang.String UPDATE
A key used to notify the model that the backingList
has changed.- See Also:
- Constant Field Values
-
data
protected final java.util.List<E> 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
protected E selected
The currently selected item.
-
-
Constructor Detail
-
ListComboBoxModel
public ListComboBoxModel(java.util.List<E> list)
Creates aListComboBoxModel
backed by the suppliedlist
.- Parameters:
list
- the list backing this model- Throws:
java.lang.NullPointerException
- iflist
isnull
-
-
Method Detail
-
setSelectedItem
public void setSelectedItem(java.lang.Object item)
Set the selected item. The implementation of this method should notify all registeredListDataListener
s that the contents have changed.- Specified by:
setSelectedItem
in interfacejavax.swing.ComboBoxModel<E>
- Parameters:
item
- the list object to select ornull
to clear the selection- Throws:
java.lang.ClassCastException
- ifitem
is not of typeE
-
getSelectedItem
public E getSelectedItem()
- Specified by:
getSelectedItem
in interfacejavax.swing.ComboBoxModel<E>
-
getElementAt
public E getElementAt(int index)
- Specified by:
getElementAt
in interfacejavax.swing.ListModel<E>
-
getSize
public int getSize()
- Specified by:
getSize
in interfacejavax.swing.ListModel<E>
-
actionPerformed
public void actionPerformed(java.awt.event.ActionEvent evt)
- Specified by:
actionPerformed
in interfacejava.awt.event.ActionListener
-
-