T - the element type in the ComboBox.public class ComboBoxSearchable<T> extends Searchable<T>
ComboBoxSearchable is an concrete implementation of Searchable that enables the search function
on non-editable ComboBox. It's very simple to use it. Assuming you have a ComboBox, all you need to do is to call
ComboBox comboBox = ....;
ComboBoxSearchable searchable = new ComboBoxSearchable(comboBox);
Now the ComboBox will have the search function.
There is very little customization you need to do to ComboBoxSearchable. The only thing you might need is when the element in the ComboBox needs a special conversion to convert to string. If so, you can override convertElementToString() to provide you own algorithm to do the conversion.
ComboBox comboBox = ....;
ComboBoxSearchable searchable = new ComboBoxSearchable(comboBox) {
protected String convertElementToString(Object object) {
...
}
};
| Type | Property and Description |
|---|---|
javafx.beans.property.BooleanProperty |
showPopup |
caeSensitiveProperty, fromStartProperty, matchingElementProperty, matchingIndexProperty, popupPositionProperty, popupPositionRelativeToProperty, repeatsProperty, searchingDelayProperty, searchingLabelProperty, searchingProperty, searchingTextProperty, typedTextProperty, wildcardEnabledPropertySearchable.SearchPopup_boundsListener, _keyListener, _node, _visibleListener, PROPERTY_SEARCHABLE| Constructor and Description |
|---|
ComboBoxSearchable(javafx.scene.control.ComboBox<T> comboBox) |
| Modifier and Type | Method and Description |
|---|---|
protected java.lang.String |
convertElementToString(T element)
Converts the element that returns from getElementAt() to string.
|
protected T |
getElementAt(int index)
Gets the element at the specified index.
|
protected int |
getElementCount()
Gets the total element count in the control.
|
protected int |
getSelectedIndex()
Gets the selected index in the control.
|
void |
installListeners()
Installs necessary listeners to the control.
|
boolean |
isShowPopup()
Gets the value of the property showPopup.
|
protected void |
setSelectedIndex(int index,
boolean incremental)
Sets the selected index.
|
void |
setShowPopup(boolean showPopup)
Sets the value of the property showPopup.
|
javafx.beans.property.BooleanProperty |
showPopupProperty() |
void |
uninstallListeners()
Uninstall the listeners that installed before.
|
adjustSelectedIndex, caeSensitiveProperty, compare, compareAsString, createSearchPopup, findAll, findFirst, findFromCursor, findLast, findNext, findPrevious, fromStartProperty, getCurrentIndex, getCursor, getElementAtAsString, getHidePopupDelay, getMatchingElement, getMatchingIndex, getNode, getPopupPosition, getPopupPositionRelativeTo, getResourceString, getSearchable, getSearchingDelay, getSearchingText, getSearchLabel, getWildcardSupport, hidePopup, highlightAll, isActivateKey, isCaseSensitive, isDeactivateKey, isFindFirstKey, isFindLastKey, isFindNextKey, isFindPreviousKey, isFromStart, isIncrementalSelectKey, isNavigationKey, isPopupVisible, isRepeats, isReverseOrder, isSearching, isSelectAllKey, isWildcardEnabled, keyTypedOrPressed, matchingElementProperty, matchingIndexProperty, popupPositionProperty, popupPositionRelativeToProperty, repeatsProperty, reverseFindFromCursor, searchingDelayProperty, searchingLabelProperty, searchingProperty, searchingTextProperty, select, setCaseSensitive, setCursor, setCursor, setFromStart, setHidePopupDelay, setMatchingElement, setMatchingIndex, setPopupPosition, setPopupPositionRelativeTo, setRepeats, setReverseOrder, setSearching, setSearchingDelay, setSearchingText, setSearchLabel, setWildcardEnabled, setWildcardSupport, showPopup, typedTextProperty, wildcardEnabledPropertypublic javafx.beans.property.BooleanProperty showPopupProperty
isShowPopup(),
setShowPopup(boolean)public ComboBoxSearchable(javafx.scene.control.ComboBox<T> comboBox)
public void installListeners()
SearchableinstallListeners in class Searchable<T>public void uninstallListeners()
SearchableuninstallListeners in class Searchable<T>public javafx.beans.property.BooleanProperty showPopupProperty()
isShowPopup(),
setShowPopup(boolean)public boolean isShowPopup()
public void setShowPopup(boolean showPopup)
protected int getSelectedIndex()
SearchableHere are some examples. In the case of ListView, the index is the row index. In the case of TreeView, the index is the row index too. In the case of TableView, depending on the selection mode, the index could be row index (in row selection mode), or could be the cell index (in cell selection mode).
getSelectedIndex in class Searchable<T>protected void setSelectedIndex(int index,
boolean incremental)
SearchablesetSelectedIndex in class Searchable<T>index - the index to be selectedincremental - a flag to enable multiple selection. If the flag is true, the element at the index should be
added to current selection. If false, you should clear previous selection and then select the
element.protected int getElementCount()
SearchablegetElementCount in class Searchable<T>protected T getElementAt(int index)
SearchablegetElementAt in class Searchable<T>index - the indexprotected java.lang.String convertElementToString(T element)
SearchableconvertElementToString in class Searchable<T>element - the element to be converted