public class KeyedComboBoxModel
extends java.lang.Object
implements javax.swing.ComboBoxModel
| Constructor and Description |
|---|
KeyedComboBoxModel()
Creates a new keyed combobox model.
|
KeyedComboBoxModel(java.lang.Object[] keys,
java.lang.Object[] values)
Creates a new keyed combobox model for the given keys and values.
|
| Modifier and Type | Method and Description |
|---|---|
void |
add(java.lang.Object key,
java.lang.Object cbitem)
Adds a new entry to the model.
|
void |
addListDataListener(javax.swing.event.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(java.lang.Object key)
Tries to find the index of element with the given key.
|
protected void |
fireListDataEvent(javax.swing.event.ListDataEvent evt)
Notifies all registered list data listener of the given event.
|
java.lang.Object |
getElementAt(int index)
Returns the value at the specified index.
|
java.lang.Object |
getKeyAt(int index)
Returns the key from the given index.
|
java.lang.Object |
getSelectedItem()
Returns the selected item.
|
java.lang.Object |
getSelectedKey()
Returns the selected data element or null if none is set.
|
int |
getSize()
Returns the length of the list.
|
void |
removeDataElement(java.lang.Object key)
Removes an entry from the model.
|
void |
removeListDataListener(javax.swing.event.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(java.lang.Object[] keys,
java.lang.Object[] values)
Replaces the data in this combobox model.
|
void |
setSelectedItem(java.lang.Object anItem)
Set the selected item.
|
void |
setSelectedKey(java.lang.Object anItem)
Defines the selected key.
|
public KeyedComboBoxModel()
public KeyedComboBoxModel(java.lang.Object[] keys,
java.lang.Object[] values)
keys - the keysvalues - the valuespublic void setData(java.lang.Object[] keys,
java.lang.Object[] values)
keys - the keysvalues - the valuesprotected void fireListDataEvent(javax.swing.event.ListDataEvent evt)
evt - the event.public java.lang.Object getSelectedItem()
getSelectedItem in interface javax.swing.ComboBoxModelnull if there is no selectionpublic void setSelectedKey(java.lang.Object anItem)
anItem - the new selected item.public void setSelectedItem(java.lang.Object anItem)
ListDataListeners that the contents have
changed.setSelectedItem in interface javax.swing.ComboBoxModelanItem - the list object to select or null to clear the
selectionpublic void setAllowOtherValue(boolean allowOtherValue)
public void addListDataListener(javax.swing.event.ListDataListener l)
addListDataListener in interface javax.swing.ListModell - the ListDataListener to be addedpublic java.lang.Object getElementAt(int index)
getElementAt in interface javax.swing.ListModelindex - the requested indexindexpublic java.lang.Object getKeyAt(int index)
index - the index of the key.public java.lang.Object getSelectedKey()
public int getSize()
getSize in interface javax.swing.ListModelpublic void removeListDataListener(javax.swing.event.ListDataListener l)
removeListDataListener in interface javax.swing.ListModell - the ListDataListener to be removedpublic int findElementIndex(java.lang.Object key)
key - the key for the element to be searched.public void removeDataElement(java.lang.Object key)
key - the keypublic void add(java.lang.Object key,
java.lang.Object cbitem)
key - the keycbitem - the display value.public void clear()