java.lang.Object
javafx.scene.control.FocusModel<T>
- Direct Known Subclasses:
TableFocusModel
The abstract base class for FocusModel implementations.
- Since:
- JavaFX 2.0
-
Property Summary
TypePropertyDescriptionfinal ReadOnlyIntegerProperty
The index of the current item in the FocusModel which has the focus.final ReadOnlyObjectProperty<T>
The current item in the FocusModel which has the focus. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
focus
(int index) Causes the item at the given index to receive the focus.final ReadOnlyIntegerProperty
The index of the current item in the FocusModel which has the focus.final ReadOnlyObjectProperty<T>
The current item in the FocusModel which has the focus.void
Attempts to give focus to the row after to the currently focused row.void
Attempts to give focus to the row previous to the currently focused row.final int
Gets the value of thefocusedIndex
property.final T
Gets the value of thefocusedItem
property.protected abstract int
Returns the number of items in the data model that underpins the control.protected abstract T
getModelItem
(int index) Returns the item at the given index.boolean
isFocused
(int index) Convenience method to inform if the given index is currently focused in this SelectionModel.
-
Property Details
-
focusedIndex
The index of the current item in the FocusModel which has the focus. It is possible that this will be -1, but only if the control is empty. If the control is not itself focused, this property will still reference the row index that would receive the keyboard focus if the control itself were focused.- See Also:
-
focusedItem
The current item in the FocusModel which has the focus. It is possible that this will be null, but only if the control is empty. If the control is not itself focused, this property will still reference the item that would receive the keyboard focus if the control itself were focused.- See Also:
-
-
Constructor Details
-
FocusModel
public FocusModel()Creates a default FocusModel instance.
-
-
Method Details
-
focusedIndexProperty
The index of the current item in the FocusModel which has the focus. It is possible that this will be -1, but only if the control is empty. If the control is not itself focused, this property will still reference the row index that would receive the keyboard focus if the control itself were focused.- Returns:
- the
focusedIndex
property - See Also:
-
getFocusedIndex
public final int getFocusedIndex()Gets the value of thefocusedIndex
property.- Property description:
- The index of the current item in the FocusModel which has the focus. It is possible that this will be -1, but only if the control is empty. If the control is not itself focused, this property will still reference the row index that would receive the keyboard focus if the control itself were focused.
- Returns:
- the value of the
focusedIndex
property - See Also:
-
focusedItemProperty
The current item in the FocusModel which has the focus. It is possible that this will be null, but only if the control is empty. If the control is not itself focused, this property will still reference the item that would receive the keyboard focus if the control itself were focused.- Returns:
- the
focusedItem
property - See Also:
-
getFocusedItem
Gets the value of thefocusedItem
property.- Property description:
- The current item in the FocusModel which has the focus. It is possible that this will be null, but only if the control is empty. If the control is not itself focused, this property will still reference the item that would receive the keyboard focus if the control itself were focused.
- Returns:
- the value of the
focusedItem
property - See Also:
-
getItemCount
protected abstract int getItemCount()Returns the number of items in the data model that underpins the control. An example would be that a ListView focus model would likely returnlistView.getItems().size()
. The valid range of focusable indices is between 0 and whatever is returned by this method.- Returns:
- the number of items in the data model that underpins the control
-
getModelItem
Returns the item at the given index. An example using ListView would belistView.getItems().get(index)
.- Parameters:
index
- The index of the item that is requested from the underlying data model.- Returns:
- Returns null if the index is out of bounds, or an element of type T that is related to the given index.
-
isFocused
public boolean isFocused(int index) Convenience method to inform if the given index is currently focused in this SelectionModel. Is functionally equivalent to calling
.getFocusedIndex() == index
- Parameters:
index
- The index to check as to whether it is currently focused or not.- Returns:
- True if the given index is focused, false otherwise.
-
focus
public void focus(int index) Causes the item at the given index to receive the focus. This does not cause the current selection to change. Updates the focusedItem and focusedIndex properties such thatfocusedIndex = -1
unless0 <= index < model size
.- Parameters:
index
- The index of the item to get focus.
-
focusPrevious
public void focusPrevious()Attempts to give focus to the row previous to the currently focused row. If the current focus owner is the first row, or is -1 (representing that there is no current focus owner), calling this method will have no result. -
focusNext
public void focusNext()Attempts to give focus to the row after to the currently focused row. If the current focus owner is the last row, calling this method will have no result.
-