Dims
Dims

Reputation: 51029

How to distinguish selected row from current row in TableView in JavaFX?

If display simple TableView sample, then select first row, then press Ctrl and then Down Arrow button two times, we will see the following picture:

enter image description here

I.e. first row remains selected, while third row get cursor.

How to know this row?

Upvotes: 2

Views: 815

Answers (1)

fabian
fabian

Reputation: 82461

This is the focused row. You can access that row via the focusModel property:

int rowIndex = tableView.getFocusModel().getFocusedIndex();

The TableView.TableViewFocusModel class used for focusModel also supports some additional features like accessing the item for the focused row.

Upvotes: 3

Related Questions