E
- the type of elements maintained by the list backing this modeljava.awt.event.ActionListener
, java.io.Serializable
, java.util.EventListener
, javax.swing.ComboBoxModel
, javax.swing.ListModel
EnumComboBoxModel
, MapComboBoxModel
public class ListComboBoxModel<E>
extends javax.swing.AbstractListModel
implements javax.swing.ComboBoxModel, java.awt.event.ActionListener
ComboBoxModel
for List
s.Modifier and Type | Field | Description |
---|---|---|
protected java.util.List<E> |
data |
A reference to the list backing this model.
|
protected E |
selected |
The currently selected item.
|
static java.lang.String |
UPDATE |
A key used to notify the model that the backing
List has changed. |
Constructor | Description |
---|---|
ListComboBoxModel(java.util.List<E> list) |
Creates a
ListComboBoxModel backed by the supplied list . |
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.
|
public static final java.lang.String UPDATE
List
has changed.protected final java.util.List<E> data
This model does not make a copy of the list, so any changes in the list without synchronizing the model may have drastic effects.
protected E selected
public ListComboBoxModel(java.util.List<E> list)
ListComboBoxModel
backed by the supplied list
.list
- the list backing this modeljava.lang.NullPointerException
- if list
is null
public void setSelectedItem(java.lang.Object item)
ListDataListener
s that the contents have changed.setSelectedItem
in interface javax.swing.ComboBoxModel<E>
item
- the list object to select or null
to clear the
selectionjava.lang.ClassCastException
- if item
is not of type E
public E getSelectedItem()
getSelectedItem
in interface javax.swing.ComboBoxModel<E>
public E getElementAt(int index)
getElementAt
in interface javax.swing.ListModel<E>
public int getSize()
getSize
in interface javax.swing.ListModel<E>
public void actionPerformed(java.awt.event.ActionEvent evt)
actionPerformed
in interface java.awt.event.ActionListener