java.lang.Object
javafx.scene.control.SelectionModel<T>
javafx.scene.control.SingleSelectionModel<T>
- 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:
- 
Property SummaryProperties declared in class javafx.scene.control.SelectionModelselectedIndex, selectedItem
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidclearAndSelect(int index) In the SingleSelectionModel, this method is functionally equivalent to callingselect(index), as only one selection is allowed at a time.voidClears the selection model of all selected indices.voidclearSelection(int index) Clears the selection of the given index, if it is currently selected.protected abstract intGets the number of items available for the selection model.protected abstract TgetModelItem(int index) Gets the data model item associated with a specific index.booleanisEmpty()This method is available to test whether there are any selected indices/items.booleanisSelected(int index) This method will return true if the given index is the currently selected index in this SingleSelectionModel.voidselect(int index) Selects the given index.voidSelects the index for the first instance of given object in the underlying data model.voidSelects the first index.voidSelects the last index.voidSelects the next index.voidSelects the previous index.Methods declared in class javafx.scene.control.SelectionModelgetSelectedIndex, getSelectedItem, selectedIndexProperty, selectedItemProperty, setSelectedIndex, setSelectedItem
- 
Constructor Details- 
SingleSelectionModelpublic SingleSelectionModel()Creates a default SingleSelectionModel instance.
 
- 
- 
Method Details- 
clearSelectionpublic void clearSelection()Clears the selection model of all selected indices. - Specified by:
- clearSelectionin class- SelectionModel<T>
 
- 
clearSelectionpublic void clearSelection(int index) Clears the selection of the given index, if it is currently selected.- Specified by:
- clearSelectionin class- SelectionModel<T>
- Parameters:
- index- The selected item to deselect.
 
- 
isEmptypublic boolean 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.- Specified by:
- isEmptyin class- SelectionModel<T>
- Returns:
- Will return true if there are no selected items, and false if there are.
 
- 
isSelectedpublic boolean isSelected(int index) This method will return true if the given index is the currently selected index in this SingleSelectionModel. - Specified by:
- isSelectedin class- SelectionModel<T>
- Parameters:
- index- The index to check as to whether it is currently selected or not.
- Returns:
- True if the given index is selected, false otherwise.
 
- 
clearAndSelectpublic void clearAndSelect(int index) In the SingleSelectionModel, this method is functionally equivalent to callingselect(index), as only one selection is allowed at a time.- Specified by:
- clearAndSelectin class- SelectionModel<T>
- Parameters:
- index- The index that should be the only selected index in this selection model.
 
- 
selectSelects 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.- Specified by:
- selectin class- SelectionModel<T>
- Parameters:
- obj- The object to attempt to select in the underlying data model.
 
- 
selectpublic void select(int index) 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.- Specified by:
- selectin class- SelectionModel<T>
- Parameters:
- index- The position of the item to select in the selection model.
 
- 
selectPreviouspublic void 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.- Specified by:
- selectPreviousin class- SelectionModel<T>
 
- 
selectNextpublic void 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.- Specified by:
- selectNextin class- SelectionModel<T>
 
- 
selectFirstpublic void 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.- Specified by:
- selectFirstin class- SelectionModel<T>
 
- 
selectLastpublic void 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.- Specified by:
- selectLastin class- SelectionModel<T>
 
- 
getModelItemGets the data model item associated with a specific index.- Parameters:
- index- The position of the item in the underlying data model.
- Returns:
- The item that exists at the given index.
 
- 
getItemCountprotected 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:
- A number greater than or equal to 0.
 
 
-