Class MultipleSelectionModel<T>

java.lang.Object
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:
TableSelectionModel

public abstract class MultipleSelectionModel<T> extends SelectionModel<T>
An abstract class that extends SelectionModel to add API to support multiple selection.
Since:
JavaFX 2.0
See Also:
  • Property Details

  • Constructor Details

    • MultipleSelectionModel

      public MultipleSelectionModel()
      Creates a default MultipleSelectionModel instance.
  • Method Details

    • 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.

      See Also:
    • 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 ListChangeListener to the returned ObservableList.

      Returns:
      the list of selected indices
    • 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 ListChangeListener to the returned ObservableList.

      Returns:
      the list of selected items
    • 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.

      Parameters:
      index - the first index to select
      indices - zero or more additional indices to select
    • 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.
      end - The last index of the selection - this index will not 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:
      selectFirst in class SelectionModel<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:
      selectLast in class SelectionModel<T>