The history manager is disabled by default, but it can be enabled using the setHistoryManager(HistoryManager) method.
We have implemented a local history manager, StringHistoryManager, which uses the Java Preferences API to store history records.
You can enable it via the setHistoryManager(HistoryManager) method.
By default, when the field loses its focus or the user presses the "enter" key (triggering the onAction event), the
text is added to the history. This behavior can be disabled by setting the addingItemToHistoryOnEnterProperty()
and / or the addingItemToHistoryOnEnterProperty() to false.
Additionally, history can be manually added based on user actions, such as after typing text and selecting an item
from a ListView or TableView that displays results, or through other interactions, by calling the getHistoryManager()
method to access the StringHistoryManager instance. then calling the StringHistoryManager#add(Object)} method.
| Modifier and Type | Field and Description |
|---|---|
| private BooleanProperty | |
| private BooleanProperty | |
| private static final boolean | |
| private static final boolean | |
| private static final boolean | |
| private static final PseudoClass | |
| private final HistoryButton | |
| private ObjectProperty | |
| private ObjectProperty | |
| private BooleanProperty |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| private void | |
| public final BooleanProperty | Returns: true if the text should be added to the history on Enter, false otherwiseDetermines whether the text of the text field should be added to the history when the user presses the Enter key. |
| public final BooleanProperty | Returns: true if the text should be added to the history on focus lost, false otherwiseDetermines whether the text of the text field should be added to the history when the field losses its focus. |
| private void | |
| private HistoryButton | |
| private StackPane | |
| public final HistoryManager | |
| public final Node | |
| public String | getUserAgentStylesheet()
Overrides org. An implementation may specify its own user-agent styles for this Region, and its children, by overriding this method. |
| public final ObjectProperty | Returns: the property representing the history managerThe history manager that is used to manage the history of the search text field. |
| public final ObjectProperty | Returns: the property representing the history placeholder nodeReturns the property representing the history placeholder node. |
| public final boolean | |
| public final boolean | |
| public final boolean | |
| public final BooleanProperty | Returns: true if the text field should have round corners, false otherwiseDetermines whether the text field should have round corners. |
| public final void | |
| public final void | |
| public final void | |
| public final void | |
| public final void |
| addingItemToHistoryOnEnter | back to summary |
|---|---|
| private BooleanProperty addingItemToHistoryOnEnter | |
| addingItemToHistoryOnFocusLost | back to summary |
|---|---|
| private BooleanProperty addingItemToHistoryOnFocusLost | |
| DEFAULT_ADDING_ITEM_TO_HISTORY_ON_ENTER | back to summary |
|---|---|
| private static final boolean DEFAULT_ADDING_ITEM_TO_HISTORY_ON_ENTER | |
| DEFAULT_ADDING_ITEM_TO_HISTORY_ON_FOCUS_LOST | back to summary |
|---|---|
| private static final boolean DEFAULT_ADDING_ITEM_TO_HISTORY_ON_FOCUS_LOST | |
| DEFAULT_ROUND | back to summary |
|---|---|
| private static final boolean DEFAULT_ROUND | |
| DISABLED_POPUP_PSEUDO_CLASS | back to summary |
|---|---|
| private static final PseudoClass DISABLED_POPUP_PSEUDO_CLASS | |
| historyButton | back to summary |
|---|---|
| private final HistoryButton<String> historyButton | |
| historyManager | back to summary |
|---|---|
| private ObjectProperty<HistoryManager<String>> historyManager | |
| historyPlaceholder | back to summary |
|---|---|
| private ObjectProperty<Node> historyPlaceholder | |
| round | back to summary |
|---|---|
| private BooleanProperty round | |
| SearchTextField | back to summary |
|---|---|
| public SearchTextField() Constructs a new text field customized for search operations. The history manager is initialized with default values. | |
| addEventHandlers | back to summary |
|---|---|
| private void addEventHandlers() | |
| addingItemToHistoryOnEnterProperty | back to summary |
|---|---|
| public final BooleanProperty addingItemToHistoryOnEnterProperty() Determines whether the text of the text field should be added to the history when the user presses the Enter key.
| |
| addingItemToHistoryOnFocusLostProperty | back to summary |
|---|---|
| public final BooleanProperty addingItemToHistoryOnFocusLostProperty() Determines whether the text of the text field should be added to the history when the field losses its focus.
| |
| addToHistory | back to summary |
|---|---|
| private void addToHistory() | |
| createHistoryButton | back to summary |
|---|---|
| private HistoryButton | |
| createRightNode | back to summary |
|---|---|
| private StackPane createRightNode() | |
| getHistoryManager | back to summary |
|---|---|
| public final HistoryManager | |
| getHistoryPlaceholder | back to summary |
|---|---|
| public final Node getHistoryPlaceholder() | |
| getUserAgentStylesheet | back to summary |
|---|---|
| public String getUserAgentStylesheet() Overrides org. Doc from org. An implementation may specify its own user-agent styles for this Region, and its children, by overriding this method. These styles are used in addition to whatever user-agent stylesheets are in use. This provides a mechanism for third parties to introduce styles for custom controls. The URL is a hierarchical URI of the form [scheme:][//authority][path]. If the URL does not have a [scheme:] component, the URL is considered to be the [path] component only. Any leading '/' character of the [path] is ignored and the [path] is treated as a path relative to the root of the application's classpath. Subclasses overriding this method should not assume any particular implementation approach as to the number and frequency with which it is called. For this reason, attempting any kind of dynamic implementation (i.e. returning different user agent stylesheet values) based on some state change is highly discouraged, as there is no guarantee when, or even if, this method will be called. Some JavaFX CSS implementations may choose to cache this response for an indefinite period of time, and therefore there should be no expectation around when this method is called.
For additional information about using CSS with the scene graph,
see the CSS Reference Guide.
| |
| historyManagerProperty | back to summary |
|---|---|
| public final ObjectProperty The history manager that is used to manage the history of the search text field. If its value is null, the history feature will not be enabled, which means only the magnifying glass icon will be displayed, and the dropdown arrow next to the magnifying glass will not be shown. If its value is not null, the history feature will be enabled, meaning that both the magnifying glass icon and the dropdown arrow will be displayed. Clicking the magnifying glass icon button will display the history popup.
To enable the history feature, you need to set an instance of
| |
| historyPlaceholderProperty | back to summary |
|---|---|
| public final ObjectProperty Returns the property representing the history placeholder node.
| |
| isAddingItemToHistoryOnEnter | back to summary |
|---|---|
| public final boolean isAddingItemToHistoryOnEnter() | |
| isAddingItemToHistoryOnFocusLost | back to summary |
|---|---|
| public final boolean isAddingItemToHistoryOnFocusLost() | |
| isRound | back to summary |
|---|---|
| public final boolean isRound() | |
| roundProperty | back to summary |
|---|---|
| public final BooleanProperty roundProperty() Determines whether the text field should have round corners.
| |
| setAddingItemToHistoryOnEnter | back to summary |
|---|---|
| public final void setAddingItemToHistoryOnEnter(boolean addingItemToHistoryOnEnter) | |
| setAddingItemToHistoryOnFocusLost | back to summary |
|---|---|
| public final void setAddingItemToHistoryOnFocusLost(boolean addingItemToHistoryOnFocusLost) | |
| setHistoryManager | back to summary |
|---|---|
| public final void setHistoryManager(HistoryManager<String> historyManager) | |
| setHistoryPlaceholder | back to summary |
|---|---|
| public final void setHistoryPlaceholder(Node historyPlaceholder) | |
| setRound | back to summary |
|---|---|
| public final void setRound(boolean round) | |