Class MultipleSelectionModel<T>
- javafx.scene.control.SelectionModel<T>
-
- javafx.scene.control.MultipleSelectionModel<T>
Type Parameters:
T - The type of the item contained in the control that can be selected.
Direct Known Subclasses:
public abstract class MultipleSelectionModel<T> extends SelectionModel<T>
SelectionModel to add API to support multiple selection.Since:
JavaFX 2.0
See Also:
-
Property Summary
All MethodsInstance MethodsConcrete Methods Type Property and Description ObjectProperty<SelectionMode>selectionModeSpecifies the selection mode to use in this selection model.-
Properties inherited from class javafx.scene.control.SelectionModel
selectedIndex, selectedItem
-
-
Constructor Summary
Constructors Constructor and Description MultipleSelectionModel()Creates a default MultipleSelectionModel instance.
-
Method Summary
All MethodsInstance MethodsAbstract MethodsConcrete Methods Modifier and Type Method and Description abstract ObservableList<Integer>getSelectedIndices()Returns a read-only ObservableList of all selected indices.abstract ObservableList<T>getSelectedItems()Returns a read-only ObservableList of all selected items.SelectionModegetSelectionMode()Gets the value of the property selectionMode.abstract voidselectAll()Convenience method to select all available indices.abstract voidselectFirst()This method will attempt to select the first index in the control.abstract voidselectIndices(int index, int... indices)This method allows for one or more selections to be set at the same time.ObjectProperty<SelectionMode>selectionModeProperty()Specifies the selection mode to use in this selection model.abstract voidselectLast()This method will attempt to select the last index in the control.voidselectRange(int start, int end)Selects all indices from the given start index to the item before the given end index.voidsetSelectionMode(SelectionMode value)Sets the value of the property selectionMode.-
Methods inherited from class javafx.scene.control.SelectionModel
clearAndSelect, clearSelection, clearSelection, getSelectedIndex, getSelectedItem, isEmpty, isSelected, select, select, selectedIndexProperty, selectedItemProperty, selectNext, selectPrevious, setSelectedIndex, setSelectedItem
-
-
Property Detail
-
selectionMode
public final ObjectProperty<SelectionMode> selectionModeProperty
Specifies the selection mode to use in this selection model. The selection mode specifies how many items in the underlying data model can be selected at any one time.
By default, the selection mode is
SelectionMode.SINGLE.
-
-
Constructor Detail
-
MultipleSelectionModel
public MultipleSelectionModel()
Creates a default MultipleSelectionModel instance.
-
-
Method Detail
-
setSelectionMode
public final void setSelectionMode(SelectionMode value)
Sets the value of the property selectionMode.Property description:
Specifies the selection mode to use in this selection model. The selection mode specifies how many items in the underlying data model can be selected at any one time.
By default, the selection mode is
SelectionMode.SINGLE.
-
getSelectionMode
public final SelectionMode getSelectionMode()
Gets the value of the property selectionMode.Property description:
Specifies the selection mode to use in this selection model. The selection mode specifies how many items in the underlying data model can be selected at any one time.
By default, the selection mode is
SelectionMode.SINGLE.
-
selectionModeProperty
public final ObjectProperty<SelectionMode> selectionModeProperty()
Specifies the selection mode to use in this selection model. The selection mode specifies how many items in the underlying data model can be selected at any one time.
By default, the selection mode is
SelectionMode.SINGLE.
-
getSelectedIndices
public abstract ObservableList<Integer> 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
ListChangeListenerto the returned ObservableList.
-
getSelectedItems
public abstract ObservableList<T> 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
ListChangeListenerto the returned ObservableList.
-
selectIndices
public abstract void selectIndices(int index, int... indices)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.
-
selectRange
public void selectRange(int start, int end)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.
Parameters:
start- The first index to select - this index will be selected.
-
selectAll
public abstract void selectAll()
Convenience method to select all available indices.
-
selectFirst
public abstract void 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.
Specified by:
selectFirstin classSelectionModel<T>
-
selectLast
public abstract void 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.
Specified by:
selectLastin classSelectionModel<T>
-
© 2008, 2025, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from JavaFX API Documentation.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Java, JavaFX and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.