T - the element type in the ListView.public class ListViewSearchable<T> extends Searchable<T>
ListViewSearchable is an concrete implementation of Searchable that enables the search function
on ListView. It's very simple to use it. Assuming you have a ListView, all you need to do is to call
ListView list = ....;
ListViewSearchable searchable = new ListViewSearchable(list);
Now the ListView will have the search function.
There is very little customization you need to do to ListViewSearchable. The only thing you might need is when the element in the ListView needs a special conversion to convert to string. If so, you can override convertElementToString() to provide you own algorithm to do the conversion.
ListView list = ....;
ListViewSearchable searchable = new ListViewSearchable(list) {
protected String convertElementToString(Object object) {
...
}
};
caeSensitiveProperty, fromStartProperty, matchingElementProperty, matchingIndexProperty, popupPositionProperty, popupPositionRelativeToProperty, repeatsProperty, searchingDelayProperty, searchingLabelProperty, searchingProperty, searchingTextProperty, typedTextProperty, wildcardEnabledPropertySearchable.SearchPopup_boundsListener, _keyListener, _node, _visibleListener, PROPERTY_SEARCHABLE| Constructor and Description |
|---|
ListViewSearchable(javafx.scene.control.ListView<T> listView) |
| 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.
|
protected void |
setSelectedIndex(int index,
boolean incremental)
Sets the selected index.
|
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 ListViewSearchable(javafx.scene.control.ListView<T> listView)
public void installListeners()
SearchableinstallListeners in class Searchable<T>public void uninstallListeners()
SearchableuninstallListeners in class Searchable<T>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