APIdia Launch Partner
Top Description Fields Constructors Methods
javafx.scene.control

public abstract Class FocusModel<T>

extends Object
Class Inheritance
Known Direct Subclasses
javafx.scene.control.ListView.ListViewFocusModel, javafx.scene.control.TableFocusModel, javafx.scene.control.TreeView.TreeViewFocusModel, com.sun.javafx.scene.control.behavior.AccordionBehavior.AccordionFocusModel
Type Parameters
<T>
the type of the focused item
Imports
javafx.beans.property.ReadOnlyIntegerProperty, .ReadOnlyIntegerWrapper, .ReadOnlyObjectProperty, .ReadOnlyObjectWrapper

The abstract base class for FocusModel implementations.
Since
JavaFX 2.0

Field Summary

Modifier and TypeField and Description
private ReadOnlyIntegerWrapper
focusedIndex

The index of the current item in the FocusModel which has the focus.

private ReadOnlyObjectWrapper<T>
focusedItem

The current item in the FocusModel which has the focus.

Constructor Summary

AccessConstructor and Description
public
FocusModel()

Creates a default FocusModel instance.

Method Summary

Modifier and TypeMethod and Description
public void
focus(int
The index of the item to get focus.
index
)

Causes the item at the given index to receive the focus.

public final ReadOnlyIntegerProperty
public final ReadOnlyObjectProperty<T>
public void
focusNext()

Attempts to give focus to the row after to the currently focused row.

public void
focusPrevious()

Attempts to give focus to the row previous to the currently focused row.

public final int
public final T
protected abstract int

Returns:

the number of items in the data model that underpins the control
getItemCount
()

Returns the number of items in the data model that underpins the control.

protected abstract T

Returns:

Returns null if the index is out of bounds, or an element of type T that is related to the given index.
getModelItem
(int
The index of the item that is requested from the underlying data model.
index
)

Returns the item at the given index.

public boolean

Returns:

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

Convenience method to inform if the given index is currently focused in this SelectionModel.

pack-priv final void
setFocusedIndex(int value)

pack-priv final void
setFocusedItem(T value)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

focusedIndexback to summary
private ReadOnlyIntegerWrapper 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.

focusedItemback to summary
private ReadOnlyObjectWrapper<T> 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.

Constructor Detail

FocusModelback to summary
public FocusModel()

Creates a default FocusModel instance.

Method Detail

focusback to summary
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 that focusedIndex = -1 unless 0 <= index < model size.

Parameters
index:int

The index of the item to get focus.

focusedIndexPropertyback to summary
public final ReadOnlyIntegerProperty focusedIndexProperty()
focusedItemPropertyback to summary
public final ReadOnlyObjectProperty<T> focusedItemProperty()
focusNextback to summary
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.

focusPreviousback to summary
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.

getFocusedIndexback to summary
public final int getFocusedIndex()
getFocusedItemback to summary
public final T getFocusedItem()
getItemCountback to summary
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 return listView.getItems().size(). The valid range of focusable indices is between 0 and whatever is returned by this method.

Returns:int

the number of items in the data model that underpins the control

getModelItemback to summary
protected abstract T getModelItem(int index)

Returns the item at the given index. An example using ListView would be listView.getItems().get(index).

Parameters
index:int

The index of the item that is requested from the underlying data model.

Returns:T

Returns null if the index is out of bounds, or an element of type T that is related to the given index.

isFocusedback to summary
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:int

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

Returns:boolean

True if the given index is focused, false otherwise.

setFocusedIndexback to summary
pack-priv final void setFocusedIndex(int value)
setFocusedItemback to summary
pack-priv final void setFocusedItem(T value)