Class MapComboBoxModel<K,V>
java.lang.Object
javax.swing.AbstractListModel
org.jdesktop.swingx.combobox.ListComboBoxModel<K>
org.jdesktop.swingx.combobox.MapComboBoxModel<K,V>
- Type Parameters:
K- the type of keys maintained by the map backing this modelV- the type of mapped values
- All Implemented Interfaces:
ActionListener, Serializable, EventListener, ComboBoxModel, ListModel
A
ComboBoxModel for Maps. The model will always present a Map
consistently, once it is instantiated. However, unless the Map is ordered, as a
java.util.TreeMap is, the model is not guaranteed to present the maps in a consistent
order between instantiations.- See Also:
-
Field Summary
FieldsFields inherited from class ListComboBoxModel
data, selected, UPDATEFields inherited from class AbstractListModel
listenerList -
Constructor Summary
ConstructorsConstructorDescriptionCreates an empty model.MapComboBoxModel(Map<K, V> map) Creates a model backed by the specified map. -
Method Summary
Modifier and TypeMethodDescriptionvoidprivate static <E> List<E> buildIndex(Map<E, ?> map) Builds an index for this model.intgetSize()getValue(int selectedItem) Selects an item from the model and returns that map value.Selects an item from the model and returns that map value.Methods inherited from class ListComboBoxModel
getElementAt, getSelectedItem, setSelectedItemMethods inherited from class AbstractListModel
addListDataListener, fireContentsChanged, fireIntervalAdded, fireIntervalRemoved, getListDataListeners, getListeners, removeListDataListenerMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ListModel
addListDataListener, removeListDataListener
-
Field Details
-
map_data
-
-
Constructor Details
-
MapComboBoxModel
public MapComboBoxModel()Creates an empty model. -
MapComboBoxModel
-
-
Method Details
-
buildIndex
Builds an index for this model. This method ensures that the map is always presented in a consistent order.This method is called by the constructor and the
Listis passed tosuper.- Type Parameters:
E- the type of keys for the map- Parameters:
map- the map to build an index for- Returns:
- a list containing the map keys
-
getSize
-
actionPerformed
- Specified by:
actionPerformedin interfaceActionListener- Overrides:
actionPerformedin classListComboBoxModel<K>
-
getValue
-
getValue
Selects an item from the model and returns that map value.- Parameters:
selectedItem- selects the item at the specified index in this model- Returns:
- the value for the item at the selected index
-