public class KeyedComboBoxModel<K,V> extends Object implements ComboBoxModel
Constructor and Description |
---|
KeyedComboBoxModel()
Creates a new keyed combobox model.
|
KeyedComboBoxModel(K[] keys,
V[] values)
Creates a new keyed combobox model for the given keys and values.
|
Modifier and Type | Method and Description |
---|---|
void |
add(K key,
V cbitem)
Adds a new entry to the model.
|
void |
addListDataListener(ListDataListener l)
Adds a listener to the list that's notified each time a change to the data model occurs.
|
void |
clear()
Removes all entries from the model.
|
int |
findElementIndex(V anItem)
Tries to find the index of element with the given value.
|
V |
getElementAt(int index)
Returns the value at the specified index.
|
K |
getKeyAt(int index)
Returns the key from the given index.
|
V |
getSelectedItem()
Returns the selected item.
|
int |
getSelectedItemIndex() |
K |
getSelectedKey()
Returns the selected data element or null if none is set.
|
int |
getSize()
Returns the length of the list.
|
void |
remove(int index) |
void |
removeDataElement(K key)
Removes an entry from the model.
|
void |
removeListDataListener(ListDataListener l)
Removes a listener from the list that's notified each time a change to the data model occurs.
|
void |
setAllowOtherValue(boolean allowOtherValue) |
void |
setData(K[] keys,
V[] values)
Replaces the data in this combobox model.
|
void |
setSelectedItem(Object anItem)
Set the selected item.
|
void |
setSelectedKey(K anItem)
Defines the selected key.
|
void |
setSelectedValue(V anItem) |
void |
update(int index,
K key,
V cbitem) |
public KeyedComboBoxModel()
public void setData(K[] keys, V[] values)
keys
- the keysvalues
- the valuespublic V getSelectedItem()
getSelectedItem
in interface ComboBoxModel
null
if there is no selectionpublic void setSelectedKey(K anItem)
anItem
- the new selected item.public final void setSelectedItem(Object anItem)
ListDataListener
s that the contents have changed.setSelectedItem
in interface ComboBoxModel
anItem
- the list object to select or null
to clear the selectionpublic void setSelectedValue(V anItem)
public void setAllowOtherValue(boolean allowOtherValue)
public void addListDataListener(ListDataListener l)
addListDataListener
in interface ListModel
l
- the ListDataListener
to be addedpublic V getElementAt(int index)
getElementAt
in interface ListModel
index
- the requested indexindex
public K getKeyAt(int index)
index
- the index of the key.public K getSelectedKey()
public int getSize()
public void removeListDataListener(ListDataListener l)
removeListDataListener
in interface ListModel
l
- the ListDataListener
to be removedpublic int findElementIndex(V anItem)
anItem
- the key for the element to be searched.public void removeDataElement(K key)
key
- the keypublic void add(K key, V cbitem)
key
- the keycbitem
- the display value.public void clear()
public int getSelectedItemIndex()
public void remove(int index)