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
ComboBoxdoes 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.
ScreenshotTo better describe what a SearchableComboBox is, please refer to the pictures below:
ExampleLet'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.
- See Also:
All Methods Instance Methods Concrete Methods Modifier and Type Method Description
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, snappedBottomInset, snappedLeftInset, snappedRightInset, snappedTopInset, snapPosition, snapPositionX, snapPositionY, snapSize, snapSizeX, snapSizeY, snapSpace, snapSpaceX, snapSpaceY, unregisterChangeListeners