Top Description Constructors Methods
javafx.scene.control

public abstract Class SingleSelectionModel<T>

extends SelectionModel<T>
Class Inheritance
Known Direct Subclasses
javafx.scene.control.TabPane.TabPaneSelectionModel, javafx.scene.control.ChoiceBox.ChoiceBoxSelectionModel, javafx.scene.control.ComboBox.ComboBoxSelectionModel
Type Parameters
<T>
The type of the item contained in the control that can be selected.

A SelectionModel which enforces the requirement that only a single index be selected at any given time. This class exists for controls that allow for pluggable selection models, but which do not allow for multiple selection. A good example is the ChoiceBox control. Conversely, most other controls (ListView, TreeView, TableView, etc) require MultipleSelectionModel implementations (although MultipleSelectionModel does still allow for single selection to be set via the selectionMode property).
Since
JavaFX 2.0
See Also
SelectionModel, MultipleSelectionModel, SelectionMode

Constructor Summary

AccessConstructor and Description
public
SingleSelectionModel()

Creates a default SingleSelectionModel instance.

Method Summary

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

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

In the SingleSelectionModel, this method is functionally equivalent to calling select(index), as only one selection is allowed at a time.

public void
clearSelection()

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

Clears the selection model of all selected indices.

public void
clearSelection(int index)

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

Clears the selection of the given index, if it is currently selected.

protected abstract int

Returns:

A number greater than or equal to 0.
getItemCount
()

Gets the number of items available for the selection model.

protected abstract T

Returns:

The item that exists at the given index.
getModelItem
(int
The position of the item in the underlying data model.
index
)

Gets the data model item associated with a specific index.

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

Returns:

True if the given index is selected, false otherwise.
isSelected
(int
The index to check as to whether it is currently selected or not.
index
)

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

This method will return true if the given index is the currently selected index in this SingleSelectionModel.

public void
select(T obj)

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

Selects the index for the first instance of given object in the underlying data model.

public void
select(int index)

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

Selects the given index.

public void
selectFirst()

Implements abstract javafx.scene.control.SelectionModel.selectFirst.

Selects the first index.

public void
selectLast()

Implements abstract javafx.scene.control.SelectionModel.selectLast.

Selects the last index.

public void
selectNext()

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

Selects the next index.

public void
selectPrevious()

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

Selects the previous index.

private void
updateSelectedIndex(int newIndex)

Inherited from javafx.scene.control.SelectionModel:
getSelectedIndexgetSelectedItemselectedIndexPropertyselectedItemPropertysetSelectedIndexsetSelectedItem

Constructor Detail

SingleSelectionModelback to summary
public SingleSelectionModel()

Creates a default SingleSelectionModel instance.

Method Detail

clearAndSelectback to summary
public void clearAndSelect(int index)

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

In the SingleSelectionModel, this method is functionally equivalent to calling select(index), as only one selection is allowed at a time.

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
clearSelectionback to summary
public void clearSelection(int index)

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

Clears the selection of the given index, if it is currently selected.

Annotations
@Override
getItemCountback to summary
protected abstract int getItemCount()

Gets the number of items available for the selection model. If the number of items can change dynamically, it is the responsibility of the concrete SingleSelectionModel implementation to ensure that items are selected or unselected as appropriate as the items change.

Returns:int

A number greater than or equal to 0.

getModelItemback to summary
protected abstract T getModelItem(int index)

Gets the data model item associated with a specific index.

Parameters
index:int

The position of the item in the underlying data model.

Returns:T

The item that exists at the given index.

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.

This method will return true if the given index is the currently selected index in this SingleSelectionModel.

Parameters
index:int

The index to check as to whether it is currently selected or not.

Returns:boolean

True if the given index is selected, false otherwise.

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

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

Selects the index for the first instance of given object in the underlying data model. Since the SingleSelectionModel can only support having a single index selected at a time, this also causes any previously selected index to be unselected.

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

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

Selects the given index. Since the SingleSelectionModel can only support having a single index selected at a time, this also causes any previously selected index to be unselected.

Annotations
@Override
selectFirstback to summary
public void selectFirst()

Implements abstract javafx.scene.control.SelectionModel.selectFirst.

Selects the first index. Since the SingleSelectionModel can only support having a single index selected at a time, this also causes any previously selected index to be unselected.

Annotations
@Override
selectLastback to summary
public void selectLast()

Implements abstract javafx.scene.control.SelectionModel.selectLast.

Selects the last index. Since the SingleSelectionModel can only support having a single index selected at a time, this also causes any previously selected index to be unselected.

Annotations
@Override
selectNextback to summary
public void selectNext()

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

Selects the next index. Since the SingleSelectionModel can only support having a single index selected at a time, this also causes any previously selected index to be unselected.

Annotations
@Override
selectPreviousback to summary
public void selectPrevious()

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

Selects the previous index. Since the SingleSelectionModel can only support having a single index selected at a time, this also causes any previously selected index to be unselected.

Annotations
@Override
updateSelectedIndexback to summary
private void updateSelectedIndex(int newIndex)