K
- the type of keys maintained by the map backing this modelV
- the type of mapped valuespublic class MapComboBoxModel<K,V> extends ListComboBoxModel<K>
ComboBoxModel
for Map
s. 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.Modifier and Type | Field and Description |
---|---|
protected Map<K,V> |
map_data
The map backing this model.
|
data, selected, UPDATE
listenerList
Constructor and Description |
---|
MapComboBoxModel()
Creates an empty model.
|
MapComboBoxModel(Map<K,V> map)
Creates a model backed by the specified map.
|
Modifier and Type | Method and Description |
---|---|
void |
actionPerformed(ActionEvent evt) |
private static <E> List<E> |
buildIndex(Map<E,?> map)
Builds an index for this model.
|
int |
getSize() |
V |
getValue(int selectedItem)
Selects an item from the model and returns that map value.
|
V |
getValue(Object selectedItem)
Selects an item from the model and returns that map value.
|
getElementAt, getSelectedItem, setSelectedItem
addListDataListener, fireContentsChanged, fireIntervalAdded, fireIntervalRemoved, getListDataListeners, getListeners, removeListDataListener
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addListDataListener, removeListDataListener
public MapComboBoxModel()
public MapComboBoxModel(Map<K,V> map)
map
- the map backing this modelprivate static <E> List<E> buildIndex(Map<E,?> map)
This method is called by the constructor and the List
is passed to super
.
E
- the type of keys for the mapmap
- the map to build an index forpublic int getSize()
getSize
in interface ListModel
getSize
in class ListComboBoxModel<K>
public void actionPerformed(ActionEvent evt)
actionPerformed
in interface ActionListener
actionPerformed
in class ListComboBoxModel<K>
public V getValue(Object selectedItem)
selectedItem
- the item to selectWebARTS Library Licensed Under the GNU - General Public License. Other Libraries licensed under their respective Open Source Licenses