- java.lang.Object
-
- javafx.scene.control.FocusModel<T>
-
- Direct Known Subclasses:
TableFocusModel
public abstract class FocusModel<T> extends Object
The abstract base class for FocusModel implementations.- Since:
- JavaFX 2.0
-
-
Property Summary
Properties Type Property Description ReadOnlyIntegerProperty
focusedIndex
The index of the current item in the FocusModel which has the focus.ReadOnlyObjectProperty<T>
focusedItem
The current item in the FocusModel which has the focus.
-
Constructor Summary
Constructors Constructor Description FocusModel()
Creates a default FocusModel instance.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
focus(int index)
Causes the item at the given index to receive the focus.ReadOnlyIntegerProperty
focusedIndexProperty()
The index of the current item in the FocusModel which has the focus.ReadOnlyObjectProperty<T>
focusedItemProperty()
The current item in the FocusModel which has the focus.void
focusNext()
Attempts to give focus to the row after to the currently focused row.void
focusPrevious()
Attempts to give focus to the row previous to the currently focused row.int
getFocusedIndex()
Gets the value of the property focusedIndex.T
getFocusedItem()
Gets the value of the property focusedItem.protected abstract int
getItemCount()
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 Detail
-
focusedIndex
public final ReadOnlyIntegerProperty 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.- See Also:
getFocusedIndex()
-
focusedItem
public final ReadOnlyObjectProperty<T> 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.- See Also:
getFocusedItem()
-
-
Method Detail
-
focusedIndexProperty
public final ReadOnlyIntegerProperty 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.- See Also:
getFocusedIndex()
-
getFocusedIndex
public final int getFocusedIndex()
Gets the value of the property focusedIndex.- 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.
-
focusedItemProperty
public final ReadOnlyObjectProperty<T> 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.- See Also:
getFocusedItem()
-
getFocusedItem
public final T getFocusedItem()
Gets the value of the property focusedItem.- 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.
-
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
protected abstract T getModelItem(int index)
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.
-
-