Class SelectableComboBox

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

public class SelectableComboBox extends JComboBox<Object>
A combobox adapted to show enabled/disabled items.
See Also:
  • Constructor Details

    • SelectableComboBox

      public SelectableComboBox()
      Constructor.
  • Method Details

    • addItem

      public void addItem(String str)
      Adds an enabled item into the combo box
      Parameters:
      str - Text of the item
    • addItem

      public void addItem(String str, boolean enabled)
      Adds an item into the combobox in either enabled or disabled state,
      Parameters:
      str - Text of the item
      enabled - The state
    • addItem

      public void addItem(Component ci)
      Add an existing item into the combobox.
      Parameters:
      ci - An existing item
    • setItem

      public void setItem(String str, boolean enabled)
      If the combobox contains str, sets its state to [@code bool}. If it's not yet an item, ignores it. The method also re-sets the selected item to the first one shown in the list as "true", and disables the listeners in this process to avoid firing an action when reorganizing the list.
      Parameters:
      str - Text of the existing item
      enabled - New state
    • getItems

      protected Object[] getItems()
    • firstTrueItem

      protected int firstTrueItem()
      Returns:
      -1 if no item is true