Class MapComboBoxModel<K,​V>

  • Type Parameters:
    K - the type of keys maintained by the map backing this model
    V - the type of mapped values
    All Implemented Interfaces:
    ActionListener, Serializable, EventListener, ComboBoxModel, ListModel

    public class MapComboBoxModel<K,​V>
    extends ListComboBoxModel<K>
    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.
    Author:
    jm158417, Karl George Schaefer
    See Also:
    Serialized Form
    • Field Detail

      • map_data

        protected Map<K,​V> map_data
        The map backing this model.
    • Constructor Detail

      • MapComboBoxModel

        public MapComboBoxModel()
        Creates an empty model.
      • MapComboBoxModel

        public MapComboBoxModel​(Map<K,​V> map)
        Creates a model backed by the specified map.
        Parameters:
        map - the map backing this model
    • Method Detail

      • getValue

        public V getValue​(Object selectedItem)
        Selects an item from the model and returns that map value.
        Parameters:
        selectedItem - the item to select
        Returns:
        the value for the selected item
      • getValue

        public V getValue​(int selectedItem)
        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