|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jfree.ui.KeyedComboBoxModel
public class KeyedComboBoxModel
The KeyedComboBox model allows to define an internal key (the data element) for every entry in the model.
This class is usefull in all cases, where the public text differs from the internal view on the data. A separation between presentation data and processing data is a prequesite for localizing combobox entries. This model does not allow selected elements, which are not in the list of valid elements.
Constructor Summary | |
---|---|
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. |
Method Summary | |
---|---|
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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public KeyedComboBoxModel()
public KeyedComboBoxModel(java.lang.Object[] keys, java.lang.Object[] values)
keys
- the keysvalues
- the valuesMethod Detail |
---|
public 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.ComboBoxModel
null
if there is no selectionpublic void setSelectedKey(java.lang.Object anItem)
anItem
- the new selected item.public void setSelectedItem(java.lang.Object anItem)
ListDataListener
s that the contents have
changed.
setSelectedItem
in interface javax.swing.ComboBoxModel
anItem
- the list object to select or null
to clear the
selectionpublic void setAllowOtherValue(boolean allowOtherValue)
allowOtherValue
- public void addListDataListener(javax.swing.event.ListDataListener l)
addListDataListener
in interface javax.swing.ListModel
l
- the ListDataListener
to be addedpublic java.lang.Object getElementAt(int index)
getElementAt
in interface javax.swing.ListModel
index
- the requested index
index
public 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.ListModel
public void removeListDataListener(javax.swing.event.ListDataListener l)
removeListDataListener
in interface javax.swing.ListModel
l
- 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()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |