Top Description Inners Fields Constructors Methods
com.dlsc.gemsfx

public Class TagsField<T>

extends SearchField<T>
Class Inheritance
Type Parameters
<T>
the type of objects to search for and to tag
Imports
com.dlsc.gemsfx.skins.TagsFieldSkin, javafx.application.Platform, javafx.beans.Observable, javafx.beans.property.DoubleProperty, .ListProperty, .ObjectProperty, .SimpleDoubleProperty, .SimpleListProperty, .SimpleObjectProperty, javafx.collections.FXCollections, .ObservableList, javafx.geometry.Orientation, javafx.scene.Node, javafx.scene.control.Label, .MultipleSelectionModel, .SelectionMode, .Skin, javafx.scene.input.KeyCode, .KeyCombination, .KeyEvent, javafx.util.Callback, java.util.*, java.util.stream.Collectors

This field is a specialization of the SearchField control and supports the additional feature of using the selected object as a tag. Tags are shown in front of the text input field. The control provides an observable list of the currently added tags. In addition, the field also allows the user to select one or more of the tags. The selection state is provided by the selection model. The field adds and removes tags via undoable commands, which means that, for example, a deleted tag can be recovered by pressing the standard undo (or redo) shortcut.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class
private class
private static interface
private class
pack-priv class

Field Summary

Modifier and TypeField and Description
private static final String
private final DoubleProperty
private final DoubleProperty
private static final int
private final Deque<TagsField.Command>
private final ListProperty<T>
private final ObjectProperty<MultipleSelectionModel<T>>
private final ObjectProperty<Callback<T, Node>>
private final Deque<TagsField.Command>

Constructor Summary

AccessConstructor and Description
public
TagsField()

Constructs a new tag field.

Method Summary

Modifier and TypeMethod and Description
public final void
addTags(T...
the value to add as a tag
values
)

Used to add one or more tags programmatically.

public final void
clearTags()

Used to clear all tags programmatically.

public void
commit()

Overrides com.dlsc.gemsfx.SearchField.commit.

Overridden to modify the behaviour for the tag field.

protected Skin<?>
createDefaultSkin()

Overrides com.dlsc.gemsfx.SearchField.createDefaultSkin.

Create a new instance of the default skin for this control.

public final DoubleProperty

Returns:

the minimum width of the editor
editorMinWidthProperty
()

The minimum width of the editor when it is not used.

public final DoubleProperty

Returns:

the preferred width of the editor
editorPrefWidthProperty
()

The preferred width of the editor when it is being used.

private void
public Orientation
getContentBias()

Overrides javafx.scene.Node.getContentBias.

Returns the orientation of a node's resizing bias for layout purposes.

public final double
public final double
public final ObservableList<T>
public final MultipleSelectionModel<T>
public final Callback<T, Node>
public String
getUserAgentStylesheet()

Overrides com.dlsc.gemsfx.SearchField.getUserAgentStylesheet.

An implementation may specify its own user-agent styles for this Region, and its children, by overriding this method.

private void
redo()

public final void
removeTags(T...
the tags to add
values
)

Used to remove one or more tags programmatically.

public final void
setEditorMinWidth(double editorMinWidth)

public final void
setEditorPrefWidth(double editorPrefWidth)

public final void
public final void
public final void
setTagViewFactory(Callback<T, Node> tagViewFactory)

public final ObjectProperty<MultipleSelectionModel<T>>

Returns:

the selection model
tagSelectionModelProperty
()

A selection model for the tags shown by the field.

public final ListProperty<T>

Returns:

the list of tags
tagsProperty
()

A list property used to store the tags.

public final ObjectProperty<Callback<T, Node>>

Returns:

a node factory for the tags
tagViewFactoryProperty
()

A callback used to create the nodes that represent the tags.

private void
undo()

protected void
update(Collection<T>
the new suggestions to use for the field
newSuggestions
)

Overrides com.dlsc.gemsfx.SearchField.update.

Overridden to remove the already tagged items from the suggestion list.

Inherited from com.dlsc.gemsfx.SearchField:
addingItemToHistoryOnCommitPropertyaddingItemToHistoryOnEnterPropertyaddingItemToHistoryOnFocusLostPropertyautoCommitOnFocusLostPropertyautoCompletedTextPropertyautoCompletionGapPropertybusyGraphicPropertycancelcellFactoryPropertyclearcomparatorPropertyconverterPropertyfullTextPropertygetAutoCompletedTextgetAutoCompletionGapgetBusyGraphicgetCellFactorygetComparatorgetConvertergetEditorgetFullTextgetGraphicgetHistoryManagergetHistoryPlaceholdergetLeftgetMatchergetNewItemProducergetOnCommitgetOnSearchFinishedgetOnSearchStartedgetPlaceholdergetPopupgetPromptTextgetRightgetSelectedItemgetSuggestionProvidergetSuggestionsgetTextgraphicPropertyhidePopupWithNoChoicePropertyhidePopupWithSingleChoicePropertyhistoryManagerPropertyhistoryPlaceholderPropertyisAddingItemToHistoryOnCommitisAddingItemToHistoryOnEnterisAddingItemToHistoryOnFocusLostisAutoCommitOnFocusLostisHidePopupWithNoChoiceisHidePopupWithSingleChoiceisNewItemisSearchingisShowSearchIconleftPropertymatcherPropertynewItemProducerPropertynewItemPropertyonCommitPropertyonSearchFinishedPropertyonSearchStartedPropertyplaceholderPropertypromptTextPropertyrightPropertysearchingPropertyselectselectedItemPropertysetAddingItemToHistoryOnCommitsetAddingItemToHistoryOnEntersetAddingItemToHistoryOnFocusLostsetAutoCommitOnFocusLostsetAutoCompletionGapsetBusyGraphicsetCellFactorysetComparatorsetConvertersetGraphicsetHidePopupWithNoChoicesetHidePopupWithSingleChoicesetHistoryManagersetHistoryPlaceholdersetLeftsetMatchersetNewItemProducersetOnCommitsetOnSearchFinishedsetOnSearchStartedsetPlaceholdersetPromptTextsetRightsetSelectedItemsetShowSearchIconsetSuggestionProvidersetTextshowSearchIconPropertysuggestionProviderPropertytextProperty

Field Detail

DEFAULT_STYLE_CLASSback to summary
private static final String DEFAULT_STYLE_CLASS

Hides com.dlsc.gemsfx.SearchField.DEFAULT_STYLE_CLASS.

editorMinWidthback to summary
private final DoubleProperty editorMinWidth
editorPrefWidthback to summary
private final DoubleProperty editorPrefWidth
MAX_UNDO_AND_REDO_STEPSback to summary
private static final int MAX_UNDO_AND_REDO_STEPS
redoStackback to summary
private final Deque<TagsField.Command> redoStack
tagsback to summary
private final ListProperty<T> tags
tagSelectionModelback to summary
private final ObjectProperty<MultipleSelectionModel<T>> tagSelectionModel
tagViewFactoryback to summary
private final ObjectProperty<Callback<T, Node>> tagViewFactory
undoStackback to summary
private final Deque<TagsField.Command> undoStack

Constructor Detail

TagsFieldback to summary
public TagsField()

Constructs a new tag field.

Method Detail

addTagsback to summary
public final void addTags(T... values)

Used to add one or more tags programmatically. This ensures that tags are added via an undoable command.

Parameters
values:T[]

the value to add as a tag

Annotations
@SafeVarargs
clearTagsback to summary
public final void clearTags()

Used to clear all tags programmatically. This ensures that tags are cleared via an undoable command.

commitback to summary
public void commit()

Overrides com.dlsc.gemsfx.SearchField.commit.

Overridden to modify the behaviour for the tag field. The override method commits the currently selected item to become a tag.

Annotations
@Override
createDefaultSkinback to summary
protected Skin<?> createDefaultSkin()

Overrides com.dlsc.gemsfx.SearchField.createDefaultSkin.

Doc from javafx.scene.control.Control.createDefaultSkin.

Create a new instance of the default skin for this control. This is called to create a skin for the control if no skin is provided via CSS -fx-skin or set explicitly in a sub-class with setSkin(...).

Annotations
@Override
editorMinWidthPropertyback to summary
public final DoubleProperty editorMinWidthProperty()

The minimum width of the editor when it is not used.

Returns:DoubleProperty

the minimum width of the editor

editorPrefWidthPropertyback to summary
public final DoubleProperty editorPrefWidthProperty()

The preferred width of the editor when it is being used.

Returns:DoubleProperty

the preferred width of the editor

executeback to summary
private void execute(TagsField.Command cmd)
getContentBiasback to summary
public Orientation getContentBias()

Overrides javafx.scene.Node.getContentBias.

Doc from javafx.scene.Node.getContentBias.

Returns the orientation of a node's resizing bias for layout purposes. If the node type has no bias, returns null. If the node is resizable and it's height depends on its width, returns HORIZONTAL, else if its width depends on its height, returns VERTICAL.

Resizable subclasses should override this method to return an appropriate value.

Annotations
@Override
getEditorMinWidthback to summary
public final double getEditorMinWidth()
getEditorPrefWidthback to summary
public final double getEditorPrefWidth()
getTagsback to summary
public final ObservableList<T> getTags()
getTagSelectionModelback to summary
public final MultipleSelectionModel<T> getTagSelectionModel()
getTagViewFactoryback to summary
public final Callback<T, Node> getTagViewFactory()
getUserAgentStylesheetback to summary
public String getUserAgentStylesheet()

Overrides com.dlsc.gemsfx.SearchField.getUserAgentStylesheet.

Doc from javafx.scene.layout.Region.getUserAgentStylesheet.

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.



package com.example.javafx.app;

import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.stage.Stage;

public class MyApp extends Application {

    @Override public void start(Stage stage) {
        Scene scene = new Scene(new Group());
        scene.getStylesheets().add("/com/example/javafx/app/mystyles.css");
        stage.setScene(scene);
        stage.show();
    }

    public static void main(String[] args) {
        launch(args);
    }
}
For additional information about using CSS with the scene graph, see the CSS Reference Guide.
Annotations
@Override
redoback to summary
private void redo()
removeTagsback to summary
public final void removeTags(T... values)

Used to remove one or more tags programmatically. This ensures that tags are removed via an undoable command.

Parameters
values:T[]

the tags to add

Annotations
@SafeVarargs
setEditorMinWidthback to summary
public final void setEditorMinWidth(double editorMinWidth)
setEditorPrefWidthback to summary
public final void setEditorPrefWidth(double editorPrefWidth)
setTagsback to summary
public final void setTags(ObservableList<T> tags)
setTagSelectionModelback to summary
public final void setTagSelectionModel(MultipleSelectionModel<T> tagSelectionModel)
setTagViewFactoryback to summary
public final void setTagViewFactory(Callback<T, Node> tagViewFactory)
tagSelectionModelPropertyback to summary
public final ObjectProperty<MultipleSelectionModel<T>> tagSelectionModelProperty()

A selection model for the tags shown by the field.

Returns:ObjectProperty<MultipleSelectionModel<T>>

the selection model

tagsPropertyback to summary
public final ListProperty<T> tagsProperty()

A list property used to store the tags.

Returns:ListProperty<T>

the list of tags

tagViewFactoryPropertyback to summary
public final ObjectProperty<Callback<T, Node>> tagViewFactoryProperty()

A callback used to create the nodes that represent the tags. The default implementation uses labels.

Returns:ObjectProperty<Callback<T, Node>>

a node factory for the tags

undoback to summary
private void undo()
updateback to summary
protected void update(Collection<T> newSuggestions)

Overrides com.dlsc.gemsfx.SearchField.update.

Overridden to remove the already tagged items from the suggestion list.

Parameters
newSuggestions:Collection<T>

the new suggestions to use for the field

Annotations
@Override
com.dlsc.gemsfx back to summary

private Class TagsField.AddTagCommand

extends Object
implements Command
Class Inheritance
All Implemented Interfaces
com.dlsc.gemsfx.TagsField.Command

Field Summary

Modifier and TypeField and Description
private final T[]

Constructor Summary

AccessConstructor and Description
public
AddTagCommand(T... tags)

Method Summary

Modifier and TypeMethod and Description
public void
public void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

tagsback to summary
private final T[] tags

Constructor Detail

AddTagCommandback to summary
public AddTagCommand(T... tags)
Annotations
@SafeVarargs

Method Detail

executeback to summary
public void execute()

Implements com.dlsc.gemsfx.TagsField.Command.execute.

Annotations
@Override
undoback to summary
public void undo()

Implements com.dlsc.gemsfx.TagsField.Command.undo.

Annotations
@Override
com.dlsc.gemsfx back to summary

private Class TagsField.ClearTagsCommand

extends Object
implements Command
Class Inheritance
All Implemented Interfaces
com.dlsc.gemsfx.TagsField.Command

Field Summary

Modifier and TypeField and Description
private final List<T>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
public void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

tagsback to summary
private final List<T> tags

Constructor Detail

ClearTagsCommandback to summary
public ClearTagsCommand(List<T> tags)

Method Detail

executeback to summary
public void execute()

Implements com.dlsc.gemsfx.TagsField.Command.execute.

Annotations
@Override
undoback to summary
public void undo()

Implements com.dlsc.gemsfx.TagsField.Command.undo.

Annotations
@Override
com.dlsc.gemsfx back to summary

private Interface TagsField.Command

Known Direct Implementers
com.dlsc.gemsfx.TagsField.AddTagCommand, com.dlsc.gemsfx.TagsField.RemoveTagCommand, com.dlsc.gemsfx.TagsField.ClearTagsCommand

Method Summary

Modifier and TypeMethod and Description
public void
public void
undo()

Method Detail

executeback to summary
public void execute()
undoback to summary
public void undo()
com.dlsc.gemsfx back to summary

private Class TagsField.RemoveTagCommand

extends Object
implements Command
Class Inheritance
All Implemented Interfaces
com.dlsc.gemsfx.TagsField.Command

Field Summary

Modifier and TypeField and Description
private final T[]

Constructor Summary

AccessConstructor and Description
public
RemoveTagCommand(T... tags)

Method Summary

Modifier and TypeMethod and Description
public void
public void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

tagsback to summary
private final T[] tags

Constructor Detail

RemoveTagCommandback to summary
public RemoveTagCommand(T... tags)
Annotations
@SafeVarargs

Method Detail

executeback to summary
public void execute()

Implements com.dlsc.gemsfx.TagsField.Command.execute.

Annotations
@Override
undoback to summary
public void undo()

Implements com.dlsc.gemsfx.TagsField.Command.undo.

Annotations
@Override
com.dlsc.gemsfx back to summary

pack-priv Class TagsField.TagFieldSelectionModel

extends MultipleSelectionModel<T>
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final ObservableList<Integer>
private final ObservableList<T>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
clearAndSelect(int index)

Implements abstract javafx.scene.control.SelectionModel.clearAndSelect.

A method that clears any selection prior to setting the selection to the given index.

public void
clearSelection(int index)

Implements abstract javafx.scene.control.SelectionModel.clearSelection.

This method will clear the selection of the item in the given index.

public void
clearSelection()

Implements abstract javafx.scene.control.SelectionModel.clearSelection.

Clears the selection model of all selected indices.

public ObservableList<Integer>
getSelectedIndices()

Implements abstract javafx.scene.control.MultipleSelectionModel.getSelectedIndices.

Returns a read-only ObservableList of all selected indices.

public ObservableList<T>
getSelectedItems()

Implements abstract javafx.scene.control.MultipleSelectionModel.getSelectedItems.

Returns a read-only ObservableList of all selected items.

public boolean
isEmpty()

Implements abstract javafx.scene.control.SelectionModel.isEmpty.

This method is available to test whether there are any selected indices/items.

public boolean
isSelected(int index)

Implements abstract javafx.scene.control.SelectionModel.isSelected.

This method tests whether the given index is currently selected in this SelectionModel.

public void
select(int index)

Implements abstract javafx.scene.control.SelectionModel.select.

This will select the given index in the selection model, assuming the index is within the valid range (i.e. greater than or equal to zero, and less than the total number of items in the underlying data model).

public void
select(T tag)

Implements abstract javafx.scene.control.SelectionModel.select.

This method will attempt to select the index that contains the given object.

public void
selectAll()

Implements abstract javafx.scene.control.MultipleSelectionModel.selectAll.

Convenience method to select all available indices.

public void
selectFirst()

Implements abstract javafx.scene.control.MultipleSelectionModel.selectFirst.

This method will attempt to select the first index in the control.

public void
selectIndices(int index, int... indices)

Implements abstract javafx.scene.control.MultipleSelectionModel.selectIndices.

This method allows for one or more selections to be set at the same time.

public void
selectLast()

Implements abstract javafx.scene.control.MultipleSelectionModel.selectLast.

This method will attempt to select the last index in the control.

public void
selectNext()

Implements abstract javafx.scene.control.SelectionModel.selectNext.

This method will attempt to select the index directly after the current focused index.

public void
selectPrevious()

Implements abstract javafx.scene.control.SelectionModel.selectPrevious.

This method will attempt to select the index directly before the current focused index.

public void
selectRange(int start, int end)

Overrides javafx.scene.control.MultipleSelectionModel.selectRange.

Selects all indices from the given start index to the item before the given end index.

Inherited from javafx.scene.control.MultipleSelectionModel:
getSelectionModeselectionModePropertysetSelectionMode

Field Detail

selectedIndicesback to summary
private final ObservableList<Integer> selectedIndices
selectedItemsback to summary
private final ObservableList<T> selectedItems

Constructor Detail

TagFieldSelectionModelback to summary
public TagFieldSelectionModel()

Method Detail

clearAndSelectback to summary
public void clearAndSelect(int index)

Implements abstract javafx.scene.control.SelectionModel.clearAndSelect.

Doc from javafx.scene.control.SelectionModel.clearAndSelect.

A method that clears any selection prior to setting the selection to the given index. The purpose of this method is to avoid having to call clearSelection() first, meaning that observers that are listening to the selected index property will not see the selected index being temporarily set to -1.

Annotations
@Override
clearSelectionback to summary
public void clearSelection(int index)

Implements abstract javafx.scene.control.SelectionModel.clearSelection.

Doc from javafx.scene.control.SelectionModel.clearSelection.

This method will clear the selection of the item in the given index. If the given index is not selected, nothing will happen.

Annotations
@Override
clearSelectionback to summary
public void clearSelection()

Implements abstract javafx.scene.control.SelectionModel.clearSelection.

Doc from javafx.scene.control.SelectionModel.clearSelection.

Clears the selection model of all selected indices.

Annotations
@Override
getSelectedIndicesback to summary
public ObservableList<Integer> getSelectedIndices()

Implements abstract javafx.scene.control.MultipleSelectionModel.getSelectedIndices.

Doc from javafx.scene.control.MultipleSelectionModel.getSelectedIndices.

Returns a read-only ObservableList of all selected indices. The ObservableList will be updated by the selection model to always reflect changes in selection. This can be observed by adding a ListChangeListener to the returned ObservableList.

Annotations
@Override
getSelectedItemsback to summary
public ObservableList<T> getSelectedItems()

Implements abstract javafx.scene.control.MultipleSelectionModel.getSelectedItems.

Doc from javafx.scene.control.MultipleSelectionModel.getSelectedItems.

Returns a read-only ObservableList of all selected items. The ObservableList will be updated further by the selection model to always reflect changes in selection. This can be observed by adding a ListChangeListener to the returned ObservableList.

Annotations
@Override
isEmptyback to summary
public boolean isEmpty()

Implements abstract javafx.scene.control.SelectionModel.isEmpty.

Doc from javafx.scene.control.SelectionModel.isEmpty.

This method is available to test whether there are any selected indices/items. It will return true if there are no selected items, and false if there are.

Annotations
@Override
isSelectedback to summary
public boolean isSelected(int index)

Implements abstract javafx.scene.control.SelectionModel.isSelected.

Doc from javafx.scene.control.SelectionModel.isSelected.

This method tests whether the given index is currently selected in this SelectionModel.

Annotations
@Override
selectback to summary
public void select(int index)

Implements abstract javafx.scene.control.SelectionModel.select.

Doc from javafx.scene.control.SelectionModel.select.

This will select the given index in the selection model, assuming the index is within the valid range (i.e. greater than or equal to zero, and less than the total number of items in the underlying data model).

If there is already one or more indices selected in this model, calling this method will not clear these selections - to do so it is necessary to first call clearSelection().

If the index is already selected, it will not be selected again, or unselected. However, if multiple selection is implemented, then calling select on an already selected index will have the effect of making the index the new selected index (as returned by getSelectedIndex().

Annotations
@Override
selectback to summary
public void select(T tag)

Implements abstract javafx.scene.control.SelectionModel.select.

Doc from javafx.scene.control.SelectionModel.select.

This method will attempt to select the index that contains the given object. It will iterate through the underlying data model until it finds an item whose value is equal to the given object. At this point it will stop iterating - this means that this method will not select multiple indices.

Annotations
@Override
selectAllback to summary
public void selectAll()

Implements abstract javafx.scene.control.MultipleSelectionModel.selectAll.

Doc from javafx.scene.control.MultipleSelectionModel.selectAll.

Convenience method to select all available indices.

Annotations
@Override
selectFirstback to summary
public void selectFirst()

Implements abstract javafx.scene.control.MultipleSelectionModel.selectFirst.

Doc from javafx.scene.control.MultipleSelectionModel.selectFirst.

This method will attempt to select the first index in the control. If clearSelection is not called first, this method will have the result of selecting the first index, whilst retaining the selection of any other currently selected indices.

If the first index is already selected, calling this method will have no result, and no selection event will take place.

Annotations
@Override
selectIndicesback to summary
public void selectIndices(int index, int... indices)

Implements abstract javafx.scene.control.MultipleSelectionModel.selectIndices.

Doc from javafx.scene.control.MultipleSelectionModel.selectIndices.

This method allows for one or more selections to be set at the same time. It will ignore any value that is not within the valid range (i.e. greater than or equal to zero, and less than the total number of items in the underlying data model). Any duplication of indices will be ignored.

If there is already one or more indices selected in this model, calling this method will not clear these selections - to do so it is necessary to first call clearSelection.

The last valid value given will become the selected index / selected item.

Annotations
@Override
selectLastback to summary
public void selectLast()

Implements abstract javafx.scene.control.MultipleSelectionModel.selectLast.

Doc from javafx.scene.control.MultipleSelectionModel.selectLast.

This method will attempt to select the last index in the control. If clearSelection is not called first, this method will have the result of selecting the last index, whilst retaining the selection of any other currently selected indices.

If the last index is already selected, calling this method will have no result, and no selection event will take place.

Annotations
@Override
selectNextback to summary
public void selectNext()

Implements abstract javafx.scene.control.SelectionModel.selectNext.

Doc from javafx.scene.control.SelectionModel.selectNext.

This method will attempt to select the index directly after the current focused index. If clearSelection is not called first, this method will have the result of selecting the next index, whilst retaining the selection of any other currently selected indices.

Calling this method will only succeed if:

  • There is currently a lead/focused index.
  • The lead/focus index is not the last index in the control.
  • The next index is not already selected.

If any of these conditions is false, no selection event will take place.

Annotations
@Override
selectPreviousback to summary
public void selectPrevious()

Implements abstract javafx.scene.control.SelectionModel.selectPrevious.

Doc from javafx.scene.control.SelectionModel.selectPrevious.

This method will attempt to select the index directly before the current focused index. If clearSelection is not called first, this method will have the result of selecting the previous index, whilst retaining the selection of any other currently selected indices.

Calling this method will only succeed if:

  • There is currently a lead/focused index.
  • The lead/focus index is not the first index in the control.
  • The previous index is not already selected.

If any of these conditions is false, no selection event will take place.

Annotations
@Override
selectRangeback to summary
public void selectRange(int start, int end)

Overrides javafx.scene.control.MultipleSelectionModel.selectRange.

Doc from javafx.scene.control.MultipleSelectionModel.selectRange.

Selects all indices from the given start index to the item before the given end index. This means that the selection is inclusive of the start index, and exclusive of the end index. This method will work regardless of whether start < end or start > end: the only constant is that the index before the given end index will become the selected index.

If there is already one or more indices selected in this model, calling this method will not clear these selections - to do so it is necessary to first call clearSelection.

Annotations
@Override