java.lang.Object
javafx.scene.Node
javafx.scene.Parent
javafx.scene.layout.Region
javafx.scene.control.Control
com.dlsc.gemsfx.SearchField<T>
- Type Parameters:
T
- the type of objects to work on
- All Implemented Interfaces:
javafx.css.Styleable
,javafx.event.EventTarget
,javafx.scene.control.Skinnable
- Direct Known Subclasses:
SearchFieldApp.CountriesSearchField
,TagsField
public class SearchField<T>
extends javafx.scene.control.Control
The search field is a standard text field with auto suggest capabilities
and a selection model for a specific type of object. This type is defined by the
generic type argument. The main difference to other auto suggest text fields is that
the main outcome of this field is an object and not just the text entered by the
user. Another difference is how the text field automatically finds and selects the
first object that matches the text typed by the user so far. A third feature of
this control is its ability to create new instances of the specified object type if
no matching object can be found in the list of objects returned by the suggestion
provider. This last feature allows an application to let the user either pick an
existing object or to create a new one on-the-fly (but only if a new item producer
has been set).
Matcher
-
Property Summary
TypePropertyDescriptionfinal javafx.beans.property.ReadOnlyStringProperty
A read-only property containing the automatically completed text.final javafx.beans.property.DoubleProperty
Defines the gap (in pixels) between the user typed text and the autocompleted text.final javafx.beans.property.ObjectProperty<javafx.scene.Node>
Stores a node that will be shown on the field's right side whenever a search is ongoing.final javafx.beans.property.ObjectProperty<javafx.util.Callback<javafx.scene.control.ListView<T>,
javafx.scene.control.ListCell<T>>> A cell factory that can be used by a list view to visualize the list of suggestions.final javafx.beans.property.ObjectProperty<Comparator<T>>
A comparator used to sort the list of suggestions.final javafx.beans.property.ObjectProperty<javafx.util.StringConverter<T>>
A converter for turning the objects returned by the suggestion provider into text.final javafx.beans.property.ReadOnlyStringProperty
A read-only property containing the concatenation of the regular text of the text field and the autocompleted text.final javafx.beans.property.ObjectProperty<javafx.scene.Node>
Stores a node that will be shown on the field's right-hand side whenever the field is idle.final javafx.beans.property.BooleanProperty
Hides the popup window with the suggestion list if the list only contains a single elements.final javafx.beans.property.ObjectProperty<javafx.scene.Node>
A custom node that can be shown on the left-hand side of the field.final javafx.beans.property.ObjectProperty<BiFunction<T,
String, Boolean>> The function that is used to determine the first item in the suggestion list that is a good match for auto selection.A callback used for creating a new object on-the-fly if no item matches the search text.final javafx.beans.property.ReadOnlyBooleanProperty
Determines if the selected item has been created on-the-fly via thenewItemProducer
.final javafx.beans.property.ObjectProperty<javafx.event.EventHandler<SearchField.SearchEvent>>
An event handler that can be used to get informed whenever the field finishes a search.final javafx.beans.property.ObjectProperty<javafx.event.EventHandler<SearchField.SearchEvent>>
An event handler that can be used to get informed whenever the field starts a search.final javafx.beans.property.ObjectProperty<javafx.scene.Node>
The placeholder UI when no suggestions have been returned by the suggestion provider.final javafx.beans.property.StringProperty
A convenience property to set the prompt text shown by the text field when no text has been entered yet (e.g.final javafx.beans.property.ObjectProperty<javafx.scene.Node>
A custom node that can be shown on the right-hand side of the field.final javafx.beans.property.ReadOnlyBooleanProperty
A flag indicating whether the asynchronous search is currently in progress.final javafx.beans.property.ObjectProperty<T>
Contains the currently selected item.final javafx.beans.property.BooleanProperty
Determines if the field will show an icon on the right-hand side which indicates that the field is a search field.final javafx.beans.property.ObjectProperty<javafx.util.Callback<SearchField.SearchFieldSuggestionRequest,
Collection<T>>> A callback used for looking up a list of suggestions for the current search text.final javafx.beans.property.StringProperty
A convenience property bound to the editor's text property.Properties inherited from class javafx.scene.control.Control
contextMenu, skin, tooltip
Properties inherited from class javafx.scene.layout.Region
background, border, cacheShape, centerShape, height, insets, maxHeight, maxWidth, minHeight, minWidth, opaqueInsets, padding, prefHeight, prefWidth, scaleShape, shape, snapToPixel, width
Properties inherited from class javafx.scene.Parent
needsLayout
Properties inherited from class javafx.scene.Node
accessibleHelp, accessibleRoleDescription, accessibleRole, accessibleText, blendMode, boundsInLocal, boundsInParent, cacheHint, cache, clip, cursor, depthTest, disabled, disable, effectiveNodeOrientation, effect, eventDispatcher, focused, focusTraversable, focusVisible, focusWithin, hover, id, inputMethodRequests, layoutBounds, layoutX, layoutY, localToParentTransform, localToSceneTransform, managed, mouseTransparent, nodeOrientation, onContextMenuRequested, onDragDetected, onDragDone, onDragDropped, onDragEntered, onDragExited, onDragOver, onInputMethodTextChanged, onKeyPressed, onKeyReleased, onKeyTyped, onMouseClicked, onMouseDragEntered, onMouseDragExited, onMouseDragged, onMouseDragOver, onMouseDragReleased, onMouseEntered, onMouseExited, onMouseMoved, onMousePressed, onMouseReleased, onRotate, onRotationFinished, onRotationStarted, onScrollFinished, onScroll, onScrollStarted, onSwipeDown, onSwipeLeft, onSwipeRight, onSwipeUp, onTouchMoved, onTouchPressed, onTouchReleased, onTouchStationary, onZoomFinished, onZoom, onZoomStarted, opacity, parent, pickOnBounds, pressed, rotate, rotationAxis, scaleX, scaleY, scaleZ, scene, style, translateX, translateY, translateZ, viewOrder, visible
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
An event type used by theSearchField
to indicate the start and end of searching operations.static class
A custom list cell implementation that is capable of underlining the part of the text that matches the user-typed search text.static interface
Represents a suggestion fetch request. -
Field Summary
Fields inherited from class javafx.scene.layout.Region
USE_COMPUTED_SIZE, USE_PREF_SIZE
Fields inherited from class javafx.scene.Node
BASELINE_OFFSET_SAME_AS_HEIGHT
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionfinal javafx.beans.property.ReadOnlyStringProperty
A read-only property containing the automatically completed text.final javafx.beans.property.DoubleProperty
Defines the gap (in pixels) between the user typed text and the autocompleted text.final javafx.beans.property.ObjectProperty<javafx.scene.Node>
Stores a node that will be shown on the field's right side whenever a search is ongoing.final void
cancel()
Cancels the current search in progress.final javafx.beans.property.ObjectProperty<javafx.util.Callback<javafx.scene.control.ListView<T>,
javafx.scene.control.ListCell<T>>> A cell factory that can be used by a list view to visualize the list of suggestions.void
clear()
Convenience method to invoke clear() on the text field.void
commit()
Makes the field commit to the currently selected item and updates the field to show the full text provided by the converter for the item.final javafx.beans.property.ObjectProperty<Comparator<T>>
A comparator used to sort the list of suggestions.final javafx.beans.property.ObjectProperty<javafx.util.StringConverter<T>>
A converter for turning the objects returned by the suggestion provider into text.protected javafx.scene.control.Skin<?>
final javafx.beans.property.ReadOnlyStringProperty
A read-only property containing the concatenation of the regular text of the text field and the autocompleted text.final String
Gets the value of theautoCompletedText
property.final double
Gets the value of theautoCompletionGap
property.final javafx.scene.Node
Gets the value of thebusyGraphic
property.Gets the value of thecellFactory
property.final Comparator<T>
Gets the value of thecomparator
property.final javafx.util.StringConverter<T>
Gets the value of theconverter
property.final javafx.scene.control.TextField
Returns the text field control used for editing the text.final String
Gets the value of thefullText
property.final javafx.scene.Node
Gets the value of thegraphic
property.final javafx.scene.Node
getLeft()
Gets the value of theleft
property.final BiFunction<T,
String, Boolean> Gets the value of thematcher
property.Gets the value of thenewItemProducer
property.final javafx.event.EventHandler<SearchField.SearchEvent>
Gets the value of theonSearchFinished
property.final javafx.event.EventHandler<SearchField.SearchEvent>
Gets the value of theonSearchStarted
property.final javafx.scene.Node
Gets the value of theplaceholder
property.final String
Gets the value of thepromptText
property.final javafx.scene.Node
getRight()
Gets the value of theright
property.final T
Gets the value of theselectedItem
property.final javafx.util.Callback<SearchField.SearchFieldSuggestionRequest,
Collection<T>> Gets the value of thesuggestionProvider
property.final javafx.collections.ObservableList<T>
Returns a read-only (unmodifiable) list of the current suggestions.final String
getText()
Gets the value of thetext
property.final javafx.beans.property.ObjectProperty<javafx.scene.Node>
Stores a node that will be shown on the field's right-hand side whenever the field is idle.final javafx.beans.property.BooleanProperty
Hides the popup window with the suggestion list if the list only contains a single elements.final boolean
Gets the value of thehidePopupWithSingleChoice
property.final boolean
Gets the value of thenewItem
property.final boolean
Gets the value of thesearching
property.final boolean
Gets the value of theshowSearchIcon
property.final javafx.beans.property.ObjectProperty<javafx.scene.Node>
A custom node that can be shown on the left-hand side of the field.final javafx.beans.property.ObjectProperty<BiFunction<T,
String, Boolean>> The function that is used to determine the first item in the suggestion list that is a good match for auto selection.A callback used for creating a new object on-the-fly if no item matches the search text.final javafx.beans.property.ReadOnlyBooleanProperty
Determines if the selected item has been created on-the-fly via thenewItemProducer
.final javafx.beans.property.ObjectProperty<javafx.event.EventHandler<SearchField.SearchEvent>>
An event handler that can be used to get informed whenever the field finishes a search.final javafx.beans.property.ObjectProperty<javafx.event.EventHandler<SearchField.SearchEvent>>
An event handler that can be used to get informed whenever the field starts a search.final javafx.beans.property.ObjectProperty<javafx.scene.Node>
The placeholder UI when no suggestions have been returned by the suggestion provider.final javafx.beans.property.StringProperty
A convenience property to set the prompt text shown by the text field when no text has been entered yet (e.g.final javafx.beans.property.ObjectProperty<javafx.scene.Node>
A custom node that can be shown on the right-hand side of the field.final javafx.beans.property.ReadOnlyBooleanProperty
A flag indicating whether the asynchronous search is currently in progress.void
Selects the given item and sets the editor's text to the string provided by the converter for the item.final javafx.beans.property.ObjectProperty<T>
Contains the currently selected item.final void
setAutoCompletionGap
(double autoCompletionGap) Sets the value of theautoCompletionGap
property.final void
setBusyGraphic
(javafx.scene.Node busyGraphic) Sets the value of thebusyGraphic
property.final void
setCellFactory
(javafx.util.Callback<javafx.scene.control.ListView<T>, javafx.scene.control.ListCell<T>> cellFactory) Sets the value of thecellFactory
property.final void
setComparator
(Comparator<T> comparator) Sets the value of thecomparator
property.final void
setConverter
(javafx.util.StringConverter<T> converter) Sets the value of theconverter
property.final void
setGraphic
(javafx.scene.Node graphic) Sets the value of thegraphic
property.final void
setHidePopupWithSingleChoice
(boolean hidePopupWithSingleChoice) Sets the value of thehidePopupWithSingleChoice
property.final void
setLeft
(javafx.scene.Node left) Sets the value of theleft
property.final void
setMatcher
(BiFunction<T, String, Boolean> matcher) Sets the value of thematcher
property.final void
setNewItemProducer
(javafx.util.Callback<String, T> newItemProducer) Sets the value of thenewItemProducer
property.final void
setOnSearchFinished
(javafx.event.EventHandler<SearchField.SearchEvent> value) Sets the value of theonSearchFinished
property.final void
setOnSearchStarted
(javafx.event.EventHandler<SearchField.SearchEvent> value) Sets the value of theonSearchStarted
property.final void
setPlaceholder
(javafx.scene.Node value) Sets the value of theplaceholder
property.final void
setPromptText
(String promptText) Sets the value of thepromptText
property.final void
setRight
(javafx.scene.Node right) Sets the value of theright
property.final void
setSelectedItem
(T selectedItem) Sets the value of theselectedItem
property.final void
setShowSearchIcon
(boolean showSearchIcon) Sets the value of theshowSearchIcon
property.final void
setSuggestionProvider
(javafx.util.Callback<SearchField.SearchFieldSuggestionRequest, Collection<T>> suggestionProvider) Sets the value of thesuggestionProvider
property.final void
Sets the value of thetext
property.final javafx.beans.property.BooleanProperty
Determines if the field will show an icon on the right-hand side which indicates that the field is a search field.final javafx.beans.property.ObjectProperty<javafx.util.Callback<SearchField.SearchFieldSuggestionRequest,
Collection<T>>> A callback used for looking up a list of suggestions for the current search text.final javafx.beans.property.StringProperty
A convenience property bound to the editor's text property.protected void
update
(Collection<T> newSuggestions) Updates the control with the newly found list of suggestions.Methods inherited from class javafx.scene.control.Control
computeMaxHeight, computeMaxWidth, computeMinHeight, computeMinWidth, computePrefHeight, computePrefWidth, contextMenuProperty, executeAccessibleAction, getBaselineOffset, getClassCssMetaData, getContextMenu, getControlCssMetaData, getCssMetaData, getInitialFocusTraversable, getSkin, getTooltip, isResizable, layoutChildren, queryAccessibleAttribute, setContextMenu, setSkin, setTooltip, skinProperty, tooltipProperty
Methods inherited from class javafx.scene.layout.Region
backgroundProperty, borderProperty, cacheShapeProperty, centerShapeProperty, getBackground, getBorder, getHeight, getInsets, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getOpaqueInsets, getPadding, getPrefHeight, getPrefWidth, getShape, getWidth, heightProperty, insetsProperty, isCacheShape, isCenterShape, isScaleShape, isSnapToPixel, layoutInArea, layoutInArea, layoutInArea, layoutInArea, maxHeight, maxHeightProperty, maxWidth, maxWidthProperty, minHeight, minHeightProperty, minWidth, minWidthProperty, opaqueInsetsProperty, paddingProperty, positionInArea, positionInArea, prefHeight, prefHeightProperty, prefWidth, prefWidthProperty, resize, scaleShapeProperty, setBackground, setBorder, setCacheShape, setCenterShape, setHeight, setMaxHeight, setMaxSize, setMaxWidth, setMinHeight, setMinSize, setMinWidth, setOpaqueInsets, setPadding, setPrefHeight, setPrefSize, setPrefWidth, setScaleShape, setShape, setSnapToPixel, setWidth, shapeProperty, snappedBottomInset, snappedLeftInset, snappedRightInset, snappedTopInset, snapPosition, snapPositionX, snapPositionY, snapSize, snapSizeX, snapSizeY, snapSpace, snapSpaceX, snapSpaceY, snapToPixelProperty, widthProperty
Methods inherited from class javafx.scene.Parent
getChildren, getChildrenUnmodifiable, getManagedChildren, getStylesheets, isNeedsLayout, layout, lookup, needsLayoutProperty, requestLayout, requestParentLayout, setNeedsLayout, updateBounds
Methods inherited from class javafx.scene.Node
accessibleHelpProperty, accessibleRoleDescriptionProperty, accessibleRoleProperty, accessibleTextProperty, addEventFilter, addEventHandler, applyCss, autosize, blendModeProperty, boundsInLocalProperty, boundsInParentProperty, buildEventDispatchChain, cacheHintProperty, cacheProperty, clipProperty, computeAreaInScreen, contains, contains, cursorProperty, depthTestProperty, disabledProperty, disableProperty, effectiveNodeOrientationProperty, effectProperty, eventDispatcherProperty, fireEvent, focusedProperty, focusTraversableProperty, focusVisibleProperty, focusWithinProperty, getAccessibleHelp, getAccessibleRole, getAccessibleRoleDescription, getAccessibleText, getBlendMode, getBoundsInLocal, getBoundsInParent, getCacheHint, getClip, getContentBias, getCursor, getDepthTest, getEffect, getEffectiveNodeOrientation, getEventDispatcher, getId, getInitialCursor, getInputMethodRequests, getLayoutBounds, getLayoutX, getLayoutY, getLocalToParentTransform, getLocalToSceneTransform, getNodeOrientation, getOnContextMenuRequested, getOnDragDetected, getOnDragDone, getOnDragDropped, getOnDragEntered, getOnDragExited, getOnDragOver, getOnInputMethodTextChanged, getOnKeyPressed, getOnKeyReleased, getOnKeyTyped, getOnMouseClicked, getOnMouseDragEntered, getOnMouseDragExited, getOnMouseDragged, getOnMouseDragOver, getOnMouseDragReleased, getOnMouseEntered, getOnMouseExited, getOnMouseMoved, getOnMousePressed, getOnMouseReleased, getOnRotate, getOnRotationFinished, getOnRotationStarted, getOnScroll, getOnScrollFinished, getOnScrollStarted, getOnSwipeDown, getOnSwipeLeft, getOnSwipeRight, getOnSwipeUp, getOnTouchMoved, getOnTouchPressed, getOnTouchReleased, getOnTouchStationary, getOnZoom, getOnZoomFinished, getOnZoomStarted, getOpacity, getParent, getProperties, getPseudoClassStates, getRotate, getRotationAxis, getScaleX, getScaleY, getScaleZ, getScene, getStyle, getStyleableParent, getStyleClass, getTransforms, getTranslateX, getTranslateY, getTranslateZ, getTypeSelector, getUserData, getViewOrder, hasProperties, hoverProperty, idProperty, inputMethodRequestsProperty, intersects, intersects, isCache, isDisable, isDisabled, isFocused, isFocusTraversable, isFocusVisible, isFocusWithin, isHover, isManaged, isMouseTransparent, isPickOnBounds, isPressed, isVisible, layoutBoundsProperty, layoutXProperty, layoutYProperty, localToParent, localToParent, localToParent, localToParent, localToParent, localToParentTransformProperty, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToSceneTransformProperty, localToScreen, localToScreen, localToScreen, localToScreen, localToScreen, lookupAll, managedProperty, mouseTransparentProperty, nodeOrientationProperty, notifyAccessibleAttributeChanged, onContextMenuRequestedProperty, onDragDetectedProperty, onDragDoneProperty, onDragDroppedProperty, onDragEnteredProperty, onDragExitedProperty, onDragOverProperty, onInputMethodTextChangedProperty, onKeyPressedProperty, onKeyReleasedProperty, onKeyTypedProperty, onMouseClickedProperty, onMouseDragEnteredProperty, onMouseDragExitedProperty, onMouseDraggedProperty, onMouseDragOverProperty, onMouseDragReleasedProperty, onMouseEnteredProperty, onMouseExitedProperty, onMouseMovedProperty, onMousePressedProperty, onMouseReleasedProperty, onRotateProperty, onRotationFinishedProperty, onRotationStartedProperty, onScrollFinishedProperty, onScrollProperty, onScrollStartedProperty, onSwipeDownProperty, onSwipeLeftProperty, onSwipeRightProperty, onSwipeUpProperty, onTouchMovedProperty, onTouchPressedProperty, onTouchReleasedProperty, onTouchStationaryProperty, onZoomFinishedProperty, onZoomProperty, onZoomStartedProperty, opacityProperty, parentProperty, parentToLocal, parentToLocal, parentToLocal, parentToLocal, parentToLocal, pickOnBoundsProperty, pressedProperty, pseudoClassStateChanged, relocate, removeEventFilter, removeEventHandler, requestFocus, resizeRelocate, rotateProperty, rotationAxisProperty, scaleXProperty, scaleYProperty, scaleZProperty, sceneProperty, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, screenToLocal, screenToLocal, screenToLocal, setAccessibleHelp, setAccessibleRole, setAccessibleRoleDescription, setAccessibleText, setBlendMode, setCache, setCacheHint, setClip, setCursor, setDepthTest, setDisable, setDisabled, setEffect, setEventDispatcher, setEventHandler, setFocused, setFocusTraversable, setHover, setId, setInputMethodRequests, setLayoutX, setLayoutY, setManaged, setMouseTransparent, setNodeOrientation, setOnContextMenuRequested, setOnDragDetected, setOnDragDone, setOnDragDropped, setOnDragEntered, setOnDragExited, setOnDragOver, setOnInputMethodTextChanged, setOnKeyPressed, setOnKeyReleased, setOnKeyTyped, setOnMouseClicked, setOnMouseDragEntered, setOnMouseDragExited, setOnMouseDragged, setOnMouseDragOver, setOnMouseDragReleased, setOnMouseEntered, setOnMouseExited, setOnMouseMoved, setOnMousePressed, setOnMouseReleased, setOnRotate, setOnRotationFinished, setOnRotationStarted, setOnScroll, setOnScrollFinished, setOnScrollStarted, setOnSwipeDown, setOnSwipeLeft, setOnSwipeRight, setOnSwipeUp, setOnTouchMoved, setOnTouchPressed, setOnTouchReleased, setOnTouchStationary, setOnZoom, setOnZoomFinished, setOnZoomStarted, setOpacity, setPickOnBounds, setPressed, setRotate, setRotationAxis, setScaleX, setScaleY, setScaleZ, setStyle, setTranslateX, setTranslateY, setTranslateZ, setUserData, setViewOrder, setVisible, snapshot, snapshot, startDragAndDrop, startFullDrag, styleProperty, toBack, toFront, toString, translateXProperty, translateYProperty, translateZProperty, usesMirroring, viewOrderProperty, visibleProperty
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface javafx.css.Styleable
getStyleableNode
-
Property Details
-
onSearchStarted
public final javafx.beans.property.ObjectProperty<javafx.event.EventHandler<SearchField.SearchEvent>> onSearchStartedPropertyAn event handler that can be used to get informed whenever the field starts a search. This event gets fired often while the user is still typing as the search gets reset with every keystroke. -
onSearchFinished
public final javafx.beans.property.ObjectProperty<javafx.event.EventHandler<SearchField.SearchEvent>> onSearchFinishedPropertyAn event handler that can be used to get informed whenever the field finishes a search. -
graphic
public final javafx.beans.property.ObjectProperty<javafx.scene.Node> graphicPropertyStores a node that will be shown on the field's right-hand side whenever the field is idle.- See Also:
-
busyGraphic
public final javafx.beans.property.ObjectProperty<javafx.scene.Node> busyGraphicPropertyStores a node that will be shown on the field's right side whenever a search is ongoing. -
hidePopupWithSingleChoice
public final javafx.beans.property.BooleanProperty hidePopupWithSingleChoicePropertyHides the popup window with the suggestion list if the list only contains a single elements. The default is "false". -
searching
public final javafx.beans.property.ReadOnlyBooleanProperty searchingPropertyA flag indicating whether the asynchronous search is currently in progress. This flag can be used to animate something that expresses that the search is ongoing.- See Also:
-
newItem
public final javafx.beans.property.ReadOnlyBooleanProperty newItemPropertyDetermines if the selected item has been created on-the-fly via thenewItemProducer
. This will only ever happen if a new item producer has been specified.- See Also:
-
cellFactory
public final javafx.beans.property.ObjectProperty<javafx.util.Callback<javafx.scene.control.ListView<T>,javafx.scene.control.ListCell<T>>> cellFactoryPropertyA cell factory that can be used by a list view to visualize the list of suggestions. -
comparator
A comparator used to sort the list of suggestions. The field will try to find a first best match inside the sorted list. Internally the control uses an "inner" comparator to ensure that suggestions appear based on the entered text, which means that a perfect match will always show up first and then the suggests that "start" with the search string. -
newItemProducer
public final javafx.beans.property.ObjectProperty<javafx.util.Callback<String,T>> newItemProducerPropertyA callback used for creating a new object on-the-fly if no item matches the search text. -
autoCompletionGap
public final javafx.beans.property.DoubleProperty autoCompletionGapPropertyDefines the gap (in pixels) between the user typed text and the autocompleted text. -
fullText
public final javafx.beans.property.ReadOnlyStringProperty fullTextPropertyA read-only property containing the concatenation of the regular text of the text field and the autocompleted text.- See Also:
-
text
public final javafx.beans.property.StringProperty textPropertyA convenience property bound to the editor's text property.- See Also:
-
promptText
public final javafx.beans.property.StringProperty promptTextPropertyA convenience property to set the prompt text shown by the text field when no text has been entered yet (e.g. "Search ..."). -
autoCompletedText
public final javafx.beans.property.ReadOnlyStringProperty autoCompletedTextPropertyA read-only property containing the automatically completed text. This property is completely managed by the control. -
matcher
The function that is used to determine the first item in the suggestion list that is a good match for auto selection. This is normally the case if the text provided by the converter for an item starts with exactly the text typed by the user. Auto selection will cause the field to automatically complete the text typed by the user with the name of the match. -
selectedItem
Contains the currently selected item. -
suggestionProvider
public final javafx.beans.property.ObjectProperty<javafx.util.Callback<SearchField.SearchFieldSuggestionRequest,Collection<T>>> suggestionProviderPropertyA callback used for looking up a list of suggestions for the current search text. -
converter
A converter for turning the objects returned by the suggestion provider into text. -
placeholder
public final javafx.beans.property.ObjectProperty<javafx.scene.Node> placeholderPropertyThe placeholder UI when no suggestions have been returned by the suggestion provider. -
left
public final javafx.beans.property.ObjectProperty<javafx.scene.Node> leftPropertyA custom node that can be shown on the left-hand side of the field.- See Also:
-
right
public final javafx.beans.property.ObjectProperty<javafx.scene.Node> rightPropertyA custom node that can be shown on the right-hand side of the field.- See Also:
-
showSearchIcon
public final javafx.beans.property.BooleanProperty showSearchIconPropertyDetermines if the field will show an icon on the right-hand side which indicates that the field is a search field.
-
-
Constructor Details
-
SearchField
public SearchField()Constructs a new spotlight field. The field will set defaults for the matcher, the converter, the cell factory, and the comparator. It will not set a default for the "new item" producer.- See Also:
-
-
Method Details
-
commit
public void commit()Makes the field commit to the currently selected item and updates the field to show the full text provided by the converter for the item. -
onSearchStartedProperty
public final javafx.beans.property.ObjectProperty<javafx.event.EventHandler<SearchField.SearchEvent>> onSearchStartedProperty()An event handler that can be used to get informed whenever the field starts a search. This event gets fired often while the user is still typing as the search gets reset with every keystroke.- Returns:
- the "search started" event handler
- See Also:
-
setOnSearchStarted
Sets the value of theonSearchStarted
property.- Property description:
- An event handler that can be used to get informed whenever the field starts a search. This event gets fired often while the user is still typing as the search gets reset with every keystroke.
- Parameters:
value
- the value for theonSearchStarted
property- See Also:
-
getOnSearchStarted
Gets the value of theonSearchStarted
property.- Property description:
- An event handler that can be used to get informed whenever the field starts a search. This event gets fired often while the user is still typing as the search gets reset with every keystroke.
- Returns:
- the value of the
onSearchStarted
property - See Also:
-
onSearchFinishedProperty
public final javafx.beans.property.ObjectProperty<javafx.event.EventHandler<SearchField.SearchEvent>> onSearchFinishedProperty()An event handler that can be used to get informed whenever the field finishes a search.- Returns:
- the "search finished" event handler
- See Also:
-
setOnSearchFinished
Sets the value of theonSearchFinished
property.- Property description:
- An event handler that can be used to get informed whenever the field finishes a search.
- Parameters:
value
- the value for theonSearchFinished
property- See Also:
-
getOnSearchFinished
Gets the value of theonSearchFinished
property.- Property description:
- An event handler that can be used to get informed whenever the field finishes a search.
- Returns:
- the value of the
onSearchFinished
property - See Also:
-
getGraphic
public final javafx.scene.Node getGraphic()Gets the value of thegraphic
property.- Property description:
- Stores a node that will be shown on the field's right-hand side whenever the field is idle.
- Returns:
- the value of the
graphic
property - See Also:
-
graphicProperty
public final javafx.beans.property.ObjectProperty<javafx.scene.Node> graphicProperty()Stores a node that will be shown on the field's right-hand side whenever the field is idle.- Returns:
- the field's graphic
- See Also:
-
setGraphic
public final void setGraphic(javafx.scene.Node graphic) Sets the value of thegraphic
property.- Property description:
- Stores a node that will be shown on the field's right-hand side whenever the field is idle.
- Parameters:
graphic
- the value for thegraphic
property- See Also:
-
getBusyGraphic
public final javafx.scene.Node getBusyGraphic()Gets the value of thebusyGraphic
property.- Property description:
- Stores a node that will be shown on the field's right side whenever a search is ongoing.
- Returns:
- the value of the
busyGraphic
property - See Also:
-
busyGraphicProperty
public final javafx.beans.property.ObjectProperty<javafx.scene.Node> busyGraphicProperty()Stores a node that will be shown on the field's right side whenever a search is ongoing.- Returns:
- the busy graphic
- See Also:
-
setBusyGraphic
public final void setBusyGraphic(javafx.scene.Node busyGraphic) Sets the value of thebusyGraphic
property.- Property description:
- Stores a node that will be shown on the field's right side whenever a search is ongoing.
- Parameters:
busyGraphic
- the value for thebusyGraphic
property- See Also:
-
isSearching
public final boolean isSearching()Gets the value of thesearching
property.- Property description:
- A flag indicating whether the asynchronous search is currently in progress. This flag can be used to animate something that expresses that the search is ongoing.
- Returns:
- the value of the
searching
property - See Also:
-
isHidePopupWithSingleChoice
public final boolean isHidePopupWithSingleChoice()Gets the value of thehidePopupWithSingleChoice
property.- Property description:
- Hides the popup window with the suggestion list if the list only contains a single elements. The default is "false".
- Returns:
- the value of the
hidePopupWithSingleChoice
property - See Also:
-
hidePopupWithSingleChoiceProperty
public final javafx.beans.property.BooleanProperty hidePopupWithSingleChoiceProperty()Hides the popup window with the suggestion list if the list only contains a single elements. The default is "false".- Returns:
- true if the popup showing the list of suggestions will not appear if only a single choice is available
- See Also:
-
setHidePopupWithSingleChoice
public final void setHidePopupWithSingleChoice(boolean hidePopupWithSingleChoice) Sets the value of thehidePopupWithSingleChoice
property.- Property description:
- Hides the popup window with the suggestion list if the list only contains a single elements. The default is "false".
- Parameters:
hidePopupWithSingleChoice
- the value for thehidePopupWithSingleChoice
property- See Also:
-
searchingProperty
public final javafx.beans.property.ReadOnlyBooleanProperty searchingProperty()A flag indicating whether the asynchronous search is currently in progress. This flag can be used to animate something that expresses that the search is ongoing.- Returns:
- true if the search is currently in progress
- See Also:
-
getEditor
public final javafx.scene.control.TextField getEditor()Returns the text field control used for editing the text.- Returns:
- the text field editor control
-
select
Selects the given item and sets the editor's text to the string provided by the converter for the item.- Parameters:
item
- the selected item
-
cancel
public final void cancel()Cancels the current search in progress. -
update
Updates the control with the newly found list of suggestions. The suggestions are provided by a background search service.- Parameters:
newSuggestions
- the new suggestions to use for the field
-
createDefaultSkin
protected javafx.scene.control.Skin<?> createDefaultSkin()- Overrides:
createDefaultSkin
in classjavafx.scene.control.Control
-
getUserAgentStylesheet
- Overrides:
getUserAgentStylesheet
in classjavafx.scene.layout.Region
-
clear
public void clear()Convenience method to invoke clear() on the text field. -
getSuggestions
Returns a read-only (unmodifiable) list of the current suggestions.- Returns:
- the list of suggestions
- See Also:
-
isNewItem
public final boolean isNewItem()Gets the value of thenewItem
property.- Property description:
- Determines if the selected item has been created on-the-fly via the
newItemProducer
. This will only ever happen if a new item producer has been specified. - Returns:
- the value of the
newItem
property - See Also:
-
newItemProperty
public final javafx.beans.property.ReadOnlyBooleanProperty newItemProperty()Determines if the selected item has been created on-the-fly via thenewItemProducer
. This will only ever happen if a new item producer has been specified.- Returns:
- true if the selected item was not part of the suggestion list and has been created on-the-fly
- See Also:
-
getCellFactory
public final javafx.util.Callback<javafx.scene.control.ListView<T>,javafx.scene.control.ListCell<T>> getCellFactory()Gets the value of thecellFactory
property.- Property description:
- A cell factory that can be used by a list view to visualize the list of suggestions.
- Returns:
- the value of the
cellFactory
property - See Also:
-
cellFactoryProperty
public final javafx.beans.property.ObjectProperty<javafx.util.Callback<javafx.scene.control.ListView<T>,javafx.scene.control.ListCell<T>>> cellFactoryProperty()A cell factory that can be used by a list view to visualize the list of suggestions.- Returns:
- the cell factory used by the suggestion list view
- See Also:
-
setCellFactory
public final void setCellFactory(javafx.util.Callback<javafx.scene.control.ListView<T>, javafx.scene.control.ListCell<T>> cellFactory) Sets the value of thecellFactory
property.- Property description:
- A cell factory that can be used by a list view to visualize the list of suggestions.
- Parameters:
cellFactory
- the value for thecellFactory
property- See Also:
-
getComparator
Gets the value of thecomparator
property.- Property description:
- A comparator used to sort the list of suggestions. The field will try to find a first best match inside the sorted list. Internally the control uses an "inner" comparator to ensure that suggestions appear based on the entered text, which means that a perfect match will always show up first and then the suggests that "start" with the search string.
- Returns:
- the value of the
comparator
property - See Also:
-
comparatorProperty
A comparator used to sort the list of suggestions. The field will try to find a first best match inside the sorted list. Internally the control uses an "inner" comparator to ensure that suggestions appear based on the entered text, which means that a perfect match will always show up first and then the suggests that "start" with the search string.- Returns:
- the sorting comparator used for the suggestions list
- See Also:
-
setComparator
Sets the value of thecomparator
property.- Property description:
- A comparator used to sort the list of suggestions. The field will try to find a first best match inside the sorted list. Internally the control uses an "inner" comparator to ensure that suggestions appear based on the entered text, which means that a perfect match will always show up first and then the suggests that "start" with the search string.
- Parameters:
comparator
- the value for thecomparator
property- See Also:
-
getNewItemProducer
Gets the value of thenewItemProducer
property.- Property description:
- A callback used for creating a new object on-the-fly if no item matches the search text.
- Returns:
- the value of the
newItemProducer
property - See Also:
-
newItemProducerProperty
public final javafx.beans.property.ObjectProperty<javafx.util.Callback<String,T>> newItemProducerProperty()A callback used for creating a new object on-the-fly if no item matches the search text.- Returns:
- the callback for producing a new object of the field supported object type
- See Also:
-
setNewItemProducer
Sets the value of thenewItemProducer
property.- Property description:
- A callback used for creating a new object on-the-fly if no item matches the search text.
- Parameters:
newItemProducer
- the value for thenewItemProducer
property- See Also:
-
getAutoCompletionGap
public final double getAutoCompletionGap()Gets the value of theautoCompletionGap
property.- Property description:
- Defines the gap (in pixels) between the user typed text and the autocompleted text.
- Returns:
- the value of the
autoCompletionGap
property - See Also:
-
autoCompletionGapProperty
public final javafx.beans.property.DoubleProperty autoCompletionGapProperty()Defines the gap (in pixels) between the user typed text and the autocompleted text.- Returns:
- the gap (in pixels) between the user typed text and the autocompleted text
- See Also:
-
setAutoCompletionGap
public final void setAutoCompletionGap(double autoCompletionGap) Sets the value of theautoCompletionGap
property.- Property description:
- Defines the gap (in pixels) between the user typed text and the autocompleted text.
- Parameters:
autoCompletionGap
- the value for theautoCompletionGap
property- See Also:
-
getFullText
Gets the value of thefullText
property.- Property description:
- A read-only property containing the concatenation of the regular text of the text field and the autocompleted text.
- Returns:
- the value of the
fullText
property - See Also:
-
fullTextProperty
public final javafx.beans.property.ReadOnlyStringProperty fullTextProperty()A read-only property containing the concatenation of the regular text of the text field and the autocompleted text.- Returns:
- the full text shown by the text field
- See Also:
-
getText
Gets the value of thetext
property.- Property description:
- A convenience property bound to the editor's text property.
- Returns:
- the value of the
text
property - See Also:
-
textProperty
public final javafx.beans.property.StringProperty textProperty()A convenience property bound to the editor's text property.- Returns:
- the text shown by the field
- See Also:
-
setText
Sets the value of thetext
property.- Property description:
- A convenience property bound to the editor's text property.
- Parameters:
text
- the value for thetext
property- See Also:
-
getPromptText
Gets the value of thepromptText
property.- Property description:
- A convenience property to set the prompt text shown by the text field when no text has been entered yet (e.g. "Search ...").
- Returns:
- the value of the
promptText
property - See Also:
-
promptTextProperty
public final javafx.beans.property.StringProperty promptTextProperty()A convenience property to set the prompt text shown by the text field when no text has been entered yet (e.g. "Search ...").- Returns:
- the prompt text
- See Also:
-
setPromptText
Sets the value of thepromptText
property.- Property description:
- A convenience property to set the prompt text shown by the text field when no text has been entered yet (e.g. "Search ...").
- Parameters:
promptText
- the value for thepromptText
property- See Also:
-
getAutoCompletedText
Gets the value of theautoCompletedText
property.- Property description:
- A read-only property containing the automatically completed text. This property is completely managed by the control.
- Returns:
- the value of the
autoCompletedText
property - See Also:
-
autoCompletedTextProperty
public final javafx.beans.property.ReadOnlyStringProperty autoCompletedTextProperty()A read-only property containing the automatically completed text. This property is completely managed by the control.- Returns:
- the auto-completed text (e.g. "ates" after the user entered "United St" in a country search field).
- See Also:
-
getMatcher
Gets the value of thematcher
property.- Property description:
- The function that is used to determine the first item in the suggestion list that is a good match for auto selection. This is normally the case if the text provided by the converter for an item starts with exactly the text typed by the user. Auto selection will cause the field to automatically complete the text typed by the user with the name of the match.
- Returns:
- the value of the
matcher
property - See Also:
-
matcherProperty
The function that is used to determine the first item in the suggestion list that is a good match for auto selection. This is normally the case if the text provided by the converter for an item starts with exactly the text typed by the user. Auto selection will cause the field to automatically complete the text typed by the user with the name of the match.- Returns:
- the function used for determining the best match in the suggestion list
- See Also:
-
setMatcher
Sets the value of thematcher
property.- Property description:
- The function that is used to determine the first item in the suggestion list that is a good match for auto selection. This is normally the case if the text provided by the converter for an item starts with exactly the text typed by the user. Auto selection will cause the field to automatically complete the text typed by the user with the name of the match.
- Parameters:
matcher
- the value for thematcher
property- See Also:
-
selectedItemProperty
Contains the currently selected item.- Returns:
- the selected item
- See Also:
-
getSelectedItem
Gets the value of theselectedItem
property.- Property description:
- Contains the currently selected item.
- Returns:
- the value of the
selectedItem
property - See Also:
-
setSelectedItem
Sets the value of theselectedItem
property.- Property description:
- Contains the currently selected item.
- Parameters:
selectedItem
- the value for theselectedItem
property- See Also:
-
getSuggestionProvider
public final javafx.util.Callback<SearchField.SearchFieldSuggestionRequest,Collection<T>> getSuggestionProvider()Gets the value of thesuggestionProvider
property.- Property description:
- A callback used for looking up a list of suggestions for the current search text.
- Returns:
- the value of the
suggestionProvider
property - See Also:
-
suggestionProviderProperty
public final javafx.beans.property.ObjectProperty<javafx.util.Callback<SearchField.SearchFieldSuggestionRequest,Collection<T>>> suggestionProviderProperty()A callback used for looking up a list of suggestions for the current search text.- Returns:
- #getSuggestions
- See Also:
-
setSuggestionProvider
public final void setSuggestionProvider(javafx.util.Callback<SearchField.SearchFieldSuggestionRequest, Collection<T>> suggestionProvider) Sets the value of thesuggestionProvider
property.- Property description:
- A callback used for looking up a list of suggestions for the current search text.
- Parameters:
suggestionProvider
- the value for thesuggestionProvider
property- See Also:
-
getConverter
Gets the value of theconverter
property.- Property description:
- A converter for turning the objects returned by the suggestion provider into text.
- Returns:
- the value of the
converter
property - See Also:
-
converterProperty
public final javafx.beans.property.ObjectProperty<javafx.util.StringConverter<T>> converterProperty()A converter for turning the objects returned by the suggestion provider into text.- Returns:
- the converter for turning the objects returned by the suggestion provider into text
- See Also:
-
setConverter
Sets the value of theconverter
property.- Property description:
- A converter for turning the objects returned by the suggestion provider into text.
- Parameters:
converter
- the value for theconverter
property- See Also:
-
placeholderProperty
public final javafx.beans.property.ObjectProperty<javafx.scene.Node> placeholderProperty()The placeholder UI when no suggestions have been returned by the suggestion provider.- Returns:
- the placeholder property for the list view of the auto suggest popup
- See Also:
-
setPlaceholder
public final void setPlaceholder(javafx.scene.Node value) Sets the value of theplaceholder
property.- Property description:
- The placeholder UI when no suggestions have been returned by the suggestion provider.
- Parameters:
value
- the value for theplaceholder
property- See Also:
-
getPlaceholder
public final javafx.scene.Node getPlaceholder()Gets the value of theplaceholder
property.- Property description:
- The placeholder UI when no suggestions have been returned by the suggestion provider.
- Returns:
- the value of the
placeholder
property - See Also:
-
getLeft
public final javafx.scene.Node getLeft()Gets the value of theleft
property.- Property description:
- A custom node that can be shown on the left-hand side of the field.
- Returns:
- the value of the
left
property - See Also:
-
leftProperty
public final javafx.beans.property.ObjectProperty<javafx.scene.Node> leftProperty()A custom node that can be shown on the left-hand side of the field.- Returns:
- a custom node for the left-hand side (e.g. "clear" button)
- See Also:
-
setLeft
public final void setLeft(javafx.scene.Node left) Sets the value of theleft
property.- Property description:
- A custom node that can be shown on the left-hand side of the field.
- Parameters:
left
- the value for theleft
property- See Also:
-
getRight
public final javafx.scene.Node getRight()Gets the value of theright
property.- Property description:
- A custom node that can be shown on the right-hand side of the field.
- Returns:
- the value of the
right
property - See Also:
-
rightProperty
public final javafx.beans.property.ObjectProperty<javafx.scene.Node> rightProperty()A custom node that can be shown on the right-hand side of the field.- Returns:
- a custom node for the right-hand side (e.g. "clear" button)
- See Also:
-
setRight
public final void setRight(javafx.scene.Node right) Sets the value of theright
property.- Property description:
- A custom node that can be shown on the right-hand side of the field.
- Parameters:
right
- the value for theright
property- See Also:
-
isShowSearchIcon
public final boolean isShowSearchIcon()Gets the value of theshowSearchIcon
property.- Property description:
- Determines if the field will show an icon on the right-hand side which indicates that the field is a search field.
- Returns:
- the value of the
showSearchIcon
property - See Also:
-
showSearchIconProperty
public final javafx.beans.property.BooleanProperty showSearchIconProperty()Determines if the field will show an icon on the right-hand side which indicates that the field is a search field.- Returns:
- true if a search icon will be shown
- See Also:
-
setShowSearchIcon
public final void setShowSearchIcon(boolean showSearchIcon) Sets the value of theshowSearchIcon
property.- Property description:
- Determines if the field will show an icon on the right-hand side which indicates that the field is a search field.
- Parameters:
showSearchIcon
- the value for theshowSearchIcon
property- See Also:
-