Class AutoCompletionComboBox

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

public class AutoCompletionComboBox extends JComboBox
An auto completion combobox. It used AutoCompletion to make the combobox auto-completing. You can use AutoCompletion directly to make any combobox auto-completing. This class is just a convenient class if all you need is an auto complete combobox.

Since auto-complete has to listen to the key user types, it has to be editable. If you want to limit user to the list available in the combobox model, you can call setStrict(boolean) and set it to true.

See Also:
  • Field Details

  • Constructor Details

    • AutoCompletionComboBox

      public AutoCompletionComboBox()
    • AutoCompletionComboBox

      public AutoCompletionComboBox(Vector<?> items)
    • AutoCompletionComboBox

      public AutoCompletionComboBox(Object[] items)
    • AutoCompletionComboBox

      public AutoCompletionComboBox(ComboBoxModel aModel)
  • Method Details

    • initComponents

      protected void initComponents()
    • createAutoCompletion

      protected AutoCompletion createAutoCompletion()
      Creates the AutoCompletion.
      Returns:
      the AutoCompletion.
    • isStrict

      public boolean isStrict()
      Gets the strict property.
      Returns:
      the value of strict property.
    • setStrict

      public void setStrict(boolean strict)
      Sets the strict property. If true, it will not allow user to type in anything that is not in the known item list. If false, user can type in whatever he/she wants. If the text can match with a item in the known item list, it will still auto-complete.
      Parameters:
      strict - true or false.
    • isStrictCompletion

      public boolean isStrictCompletion()
      Gets the strict completion property.
      Returns:
      the value of strict completion property.
      See Also:
    • setStrictCompletion

      public void setStrictCompletion(boolean strictCompletion)
      Sets the strict completion property. If true, in case insensitive searching, it will always use the exact item in the Searchable to replace whatever user types. For example, when Searchable has an item "Arial" and user types in "AR", if this flag is true, it will auto-completed as "Arial". If false, it will be auto-completed as "ARial". Of course, this flag will only make a difference if Searchable is case insensitive.
      Parameters:
      strictCompletion -
    • getAutoCompletion

      public AutoCompletion getAutoCompletion()
      Gets the underlying AutoCompletion class.
      Returns:
      the underlying AutoCompletion.
    • fireActionEvent

      protected void fireActionEvent()
      Overrides:
      fireActionEvent in class JComboBox