T
- The type of the item contained in the control that can be selected.public abstract class SingleSelectionModel<T> extends SelectionModel<T>
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).SelectionModel
,
MultipleSelectionModel
,
SelectionMode
selectedIndex, selectedItem
Constructor and Description |
---|
SingleSelectionModel()
Creates a default SingleSelectionModel instance.
|
Modifier and Type | Method and Description |
---|---|
void |
clearAndSelect(int index)
In the SingleSelectionModel, this method is functionally equivalent to
calling
select(index) , as only one selection is allowed at
a time. |
void |
clearSelection()
Clears the selection model of all selected indices.
|
void |
clearSelection(int index)
Clears the selection of the given index, if it is currently selected.
|
protected abstract int |
getItemCount()
Gets the number of items available for the selection model.
|
protected abstract T |
getModelItem(int index)
Gets the data model item associated with a specific index.
|
boolean |
isEmpty()
This method is available to test whether there are any selected
indices/items.
|
boolean |
isSelected(int index)
This method will return true if the given index is the currently
selected index in this SingleSelectionModel..
|
void |
select(int index)
Selects the given index.
|
void |
select(T obj)
Selects the index for the first instance of given object in the underlying
data model.
|
void |
selectFirst()
Selects the first index.
|
void |
selectLast()
Selects the last index.
|
void |
selectNext()
Selects the next index.
|
void |
selectPrevious()
Selects the previous index.
|
getSelectedIndex, getSelectedItem, selectedIndexProperty, selectedItemProperty, setSelectedIndex, setSelectedItem
public SingleSelectionModel()
public void clearSelection()
Clears the selection model of all selected indices.
clearSelection
in class SelectionModel<T>
public void clearSelection(int index)
clearSelection
in class SelectionModel<T>
index
- The selected item to deselect.public boolean isEmpty()
isEmpty
in class SelectionModel<T>
public boolean isSelected(int index)
This method will return true if the given index is the currently selected index in this SingleSelectionModel..
isSelected
in class SelectionModel<T>
index
- The index to check as to whether it is currently selected
or not.public void clearAndSelect(int index)
select(index)
, as only one selection is allowed at
a time.clearAndSelect
in class SelectionModel<T>
index
- The index that should be the only selected index in this
selection model.public void select(T obj)
select
in class SelectionModel<T>
obj
- The object to attempt to select in the underlying data model.public void select(int index)
select
in class SelectionModel<T>
index
- The position of the item to select in the selection model.public void selectPrevious()
selectPrevious
in class SelectionModel<T>
public void selectNext()
selectNext
in class SelectionModel<T>
public void selectFirst()
selectFirst
in class SelectionModel<T>
public void selectLast()
selectLast
in class SelectionModel<T>
protected abstract T getModelItem(int index)
index
- The position of the item in the underlying data model.protected abstract int getItemCount()
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 2008, 2017, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.