Class EnumComboBox

All Implemented Interfaces:
ActionListener, ImageObserver, ItemSelectable, MenuContainer, Serializable, EventListener, Accessible, ListDataListener

public class EnumComboBox extends JComboBox
See Also:
  • Field Details

  • Constructor Details

    • EnumComboBox

      public EnumComboBox(EnumMap<?,String> enumMap, Enum<?> defaultKey)
      Create a combobox from an enum map.
      Parameters:
      enumMap - an EnumMap<enum, String>. The enum is the key, and the string, which will become the label, is the value.
      defaultKey - the enum that should default to "on".
    • EnumComboBox

      public EnumComboBox(EnumMap<?,String> enumMap, Enum<?> defaultKey, String extraChoice)
      Create a combobox from an enum map.
      Parameters:
      enumMap - an EnumMap<enum, String>. The enum is the key, and the string, which will become the label, is the value.
      defaultKey - the enum that should default to "on".
      extraChoice - an optional extra choice, like "None" or "Any"
  • Method Details

    • getSelectedEnum

      public Enum<?> getSelectedEnum()
      Get the enum corresponding to the selected string, which is the nice name of the enum.
      Returns:
      the selected enum value. Returns null if "extra choice" was used and selected.
    • sizeComboBox

      protected void sizeComboBox()