Class SearchableComboBoxSkin<T>

java.lang.Object
javafx.scene.control.SkinBase<javafx.scene.control.ComboBox<T>>
impl.org.controlsfx.skin.SearchableComboBoxSkin<T>
All Implemented Interfaces:
javafx.scene.control.Skin<javafx.scene.control.ComboBox<T>>

public class SearchableComboBoxSkin<T> extends javafx.scene.control.SkinBase<javafx.scene.control.ComboBox<T>>
A simple skin for a ComboBox, which shows a search field while the popup is showing. The user can type any text into this search field to filter the popup list.

The user can type multiple words. The popup list is filtered checking if the string representation of an item contains all filter words (ignoring case).

After filtering the list, the user can select an entry by

  • Pressing ENTER: the selected item is applied, the popup closes. If no item is selected, the first item is applied. To select another item the cursor keys can be used before pressing ENTER.
  • Pressing TAB: Same as ENTER, but in addition the focus is transferred to the next control.
  • Selecting an item using the mouse closes the popup.

When pressing ESCAPE while the popup is showing, the item that was selected when the popup opened will be re-selected (even if the user did select another item using the cursor keys.

Other than the ComboBox, the SearchableComboBox does open the Popup when using the cursor keys (the ComboBox does only change the selected item without opening the popup). This combined with the behavior of the ESCAPE key does allow to go through the list of items with the cursor keys and than press ESCAPE to revert the changes.

Screenshot

To better describe what a SearchableComboBox is, please refer to the pictures below:
Screenshot of SearchableComboBox Screenshot of SearchableComboBox Screenshot of SearchableComboBox

Example

Let's look at an example to clarify this. The combo box offers the items ["Berlin", "Bern", "Munich", "Paris", "New York", "Alberta"]. The user now types "ber" into the search field. The combo box popup will only show ["Berlin", "Bern", "Alberta"].

To select the first item ("Berlin"), the user can now either just press ENTER or TAB, or first select this item using the cursor DOWN key and press ENTER or TAB afterwards, or select this item using the mouse.

To select the second or third item, the user either must use the cursor keys first, use the mouse, or type more text until the searched item is the first (or only) item in the list.

If you want to modify an existing ComboBox you can set the skin to SearchableComboBoxSkin (e.g. using Control.setSkin(Skin) or in CSS.

See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    SearchableComboBoxSkin(javafx.scene.control.ComboBox<T> comboBox)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    layoutChildren(double x, double y, double w, double h)
     

    Methods inherited from class javafx.scene.control.SkinBase

    computeBaselineOffset, computeMaxHeight, computeMaxWidth, computeMinHeight, computeMinWidth, computePrefHeight, computePrefWidth, consumeMouseEvents, dispose, executeAccessibleAction, getChildren, getClassCssMetaData, getCssMetaData, getNode, getSkinnable, layoutInArea, layoutInArea, layoutInArea, positionInArea, positionInArea, pseudoClassStateChanged, queryAccessibleAttribute, registerChangeListener, registerInvalidationListener, registerListChangeListener, snappedBottomInset, snappedLeftInset, snappedRightInset, snappedTopInset, snapPosition, snapPositionX, snapPositionY, snapSize, snapSizeX, snapSizeY, snapSpace, snapSpaceX, snapSpaceY, unregisterChangeListeners, unregisterInvalidationListeners, unregisterListChangeListeners

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • SearchableComboBoxSkin

      public SearchableComboBoxSkin(javafx.scene.control.ComboBox<T> comboBox)
  • Method Details

    • layoutChildren

      protected void layoutChildren(double x, double y, double w, double h)
      Overrides:
      layoutChildren in class javafx.scene.control.SkinBase<javafx.scene.control.ComboBox<T>>