TableView.TableViewFocusModel (JavaFX 27)
Description: declaration: module: javafx.controls, package: javafx.scene.control, class: TableView, class: TableViewFocusModel

# Class TableView.TableViewFocusModel<S>

java.lang.Object
javafx.scene.control.FocusModel<S>
javafx.scene.control.TableFocusModel<S, TableColumn<S,?>>
javafx.scene.control.TableView.TableViewFocusModel<S>

Type Parameters:
  `S` - the type of the item contained within the TableView

Enclosing class:
  `TableView<S>`

public static class TableView.TableViewFocusModel<S> extends TableFocusModel<S, TableColumn<S,?>>
A `FocusModel` with additional functionality to support the requirements of a TableView control.

Since:
  JavaFX 2.0
See Also:
  - `TableView`

- ## Property Summary

  Properties
  Type
  Property
  Description
  `final ReadOnlyObjectProperty<TablePosition>`
  `focusedCell`
  The position of the current item in the TableView which has the focus.

  ### Properties declared in class FocusModel

  `focusedIndex, focusedItem`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `TableViewFocusModel(TableView<S> tableView)`
  Creates a default TableViewFocusModel instance that will be used to manage focus of the provided TableView control.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `focus(int index)`
  Causes the item at the given index to receive the focus.
  `void`
  `focus(int row, TableColumn<S,?> column)`
  Causes the item at the given index to receive the focus.
  `void`
  `focus(TablePosition pos)`
  Convenience method for setting focus on a particular row or cell using a `TablePosition`.
  `void`
  `focusAboveCell()`
  Attempts to move focus to the cell above the currently focused cell.
  `void`
  `focusBelowCell()`
  Attempts to move focus to the cell below the currently focused cell.
  `final ReadOnlyObjectProperty<TablePosition>`
  `focusedCellProperty()`
  The position of the current item in the TableView which has the focus.
  `void`
  `focusLeftCell()`
  Attempts to move focus to the cell to the left of the currently focused cell.
  `void`
  `focusRightCell()`
  Attempts to move focus to the cell to the right of the the currently focused cell.
  `final TablePosition`
  `getFocusedCell()`
  Gets the value of the `focusedCell` property.
  `protected int`
  `getItemCount()`
  Returns the number of items in the data model that underpins the control.
  `protected S`
  `getModelItem(int index)`
  Returns the item at the given index.
  `boolean`
  `isFocused(int row, TableColumn<S,?> column)`
  Tests whether the row / cell at the given location currently has the focus within the TableView.

  ### Methods declared in class FocusModel

  `focusedIndexProperty, focusedItemProperty, focusNext, focusPrevious, getFocusedIndex, getFocusedItem, isFocused`

  ### Methods declared in class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Property Details

  - ### focusedCell

    public final ReadOnlyObjectProperty<TablePosition> focusedCellProperty
    The position of the current item in the TableView which has the focus.
    See Also:
      - `getFocusedCell()`
      - `focusedCellProperty()`

- ## Constructor Details

  - ### TableViewFocusModel

    public TableViewFocusModel(TableView<S> tableView)
    Creates a default TableViewFocusModel instance that will be used to manage focus of the provided TableView control.
    Parameters:
      `tableView` - The tableView upon which this focus model operates.
    Throws:
      `NullPointerException` - The TableView argument can not be null.

- ## Method Details

  - ### getItemCount

    protected 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.
    Specified by:
      `getItemCount` in class `FocusModel<S>`
    Returns:
      the number of items in the data model that underpins the control

  - ### getModelItem

    protected S getModelItem(int index)
    Returns the item at the given index. An example using ListView would be `listView.getItems().get(index)`.
    Specified by:
      `getModelItem` in class `FocusModel<S>`
    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.

  - ### focusedCellProperty

    public final ReadOnlyObjectProperty<TablePosition> focusedCellProperty()
    The position of the current item in the TableView which has the focus.
    Returns:
      the `focusedCell` property
    See Also:
      - `getFocusedCell()`

  - ### getFocusedCell

    public final TablePosition getFocusedCell()
    Gets the value of the `focusedCell` property.
    Property description:
      The position of the current item in the TableView which has the focus.
    Returns:
      the value of the `focusedCell` property
    See Also:
      - `focusedCellProperty()`

  - ### focus

    public void focus(int row, TableColumn<S,?> column)
    Causes the item at the given index to receive the focus.
    Specified by:
      `focus` in class `TableFocusModel<S, TableColumn<S,?>>`
    Parameters:
      `row` - The row index of the item to give focus to.
      `column` - The column of the item to give focus to. Can be null.

  - ### focus

    public void focus(TablePosition pos)
    Convenience method for setting focus on a particular row or cell using a `TablePosition`.
    Parameters:
      `pos` - The table position where focus should be set.

  - ### isFocused

    public boolean isFocused(int row, TableColumn<S,?> column)
    Tests whether the row / cell at the given location currently has the focus within the TableView.
    Specified by:
      `isFocused` in class `TableFocusModel<S, TableColumn<S,?>>`
    Parameters:
      `row` - the row
      `column` - the column
    Returns:
      true if the row / cell at the given location currently has the focus within the UI control

  - ### 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 that `focusedIndex = -1` unless

        0 <= index < model size

    .
    Overrides:
      `focus` in class `FocusModel<S>`
    Parameters:
      `index` - The index of the item to get focus.

  - ### focusAboveCell

    public void focusAboveCell()
    Attempts to move focus to the cell above the currently focused cell.
    Specified by:
      `focusAboveCell` in class `TableFocusModel<S, TableColumn<S,?>>`

  - ### focusBelowCell

    public void focusBelowCell()
    Attempts to move focus to the cell below the currently focused cell.
    Specified by:
      `focusBelowCell` in class `TableFocusModel<S, TableColumn<S,?>>`

  - ### focusLeftCell

    public void focusLeftCell()
    Attempts to move focus to the cell to the left of the currently focused cell.
    Specified by:
      `focusLeftCell` in class `TableFocusModel<S, TableColumn<S,?>>`

  - ### focusRightCell

    public void focusRightCell()
    Attempts to move focus to the cell to the right of the the currently focused cell.
    Specified by:
      `focusRightCell` in class `TableFocusModel<S, TableColumn<S,?>>`