Save This Page
Home » jcommon-1.0.13 » org.jfree.ui » [javadoc | source]
org.jfree.ui
public class: KeyedComboBoxModel [javadoc | source]
java.lang.Object
   org.jfree.ui.KeyedComboBoxModel

All Implemented Interfaces:
    ComboBoxModel

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:
 public KeyedComboBoxModel() 
 public KeyedComboBoxModel(Object[] keys,
    Object[] values) 
    Creates a new keyed combobox model for the given keys and values. Keys and values must have the same number of items.
    Parameters:
    keys - the keys
    values - the values
Method from org.jfree.ui.KeyedComboBoxModel Summary:
add,   addListDataListener,   clear,   findElementIndex,   fireListDataEvent,   getElementAt,   getKeyAt,   getSelectedItem,   getSelectedKey,   getSize,   removeDataElement,   removeListDataListener,   setAllowOtherValue,   setData,   setSelectedItem,   setSelectedKey
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.jfree.ui.KeyedComboBoxModel Detail:
 public  void add(Object key,
    Object cbitem) 
    Adds a new entry to the model.
 public synchronized  void addListDataListener(ListDataListener l) 
    Adds a listener to the list that's notified each time a change to the data model occurs.
 public  void clear() 
    Removes all entries from the model.
 public int findElementIndex(Object key) 
    Tries to find the index of element with the given key. The key must not be null.
 protected synchronized  void fireListDataEvent(ListDataEvent evt) 
    Notifies all registered list data listener of the given event.
 public Object getElementAt(int index) 
    Returns the value at the specified index.
 public Object getKeyAt(int index) 
    Returns the key from the given index.
 public Object getSelectedItem() 
    Returns the selected item.
 public Object getSelectedKey() 
    Returns the selected data element or null if none is set.
 public int getSize() 
    Returns the length of the list.
 public  void removeDataElement(Object key) 
    Removes an entry from the model.
 public  void removeListDataListener(ListDataListener l) 
    Removes a listener from the list that's notified each time a change to the data model occurs.
 public  void setAllowOtherValue(boolean allowOtherValue) 
 public  void setData(Object[] keys,
    Object[] values) 
    Replaces the data in this combobox model. The number of keys must be equals to the number of values.
 public  void setSelectedItem(Object anItem) 
    Set the selected item. The implementation of this method should notify all registered ListDataListeners that the contents have changed.
 public  void setSelectedKey(Object anItem) 
    Defines the selected key. If the object is not in the list of values, no item gets selected.