I managed to highlight the entire line as I need using this code
[SRC java] table.setRowFactory((TableView<MyClass> paramP) -> new TableRow<MyClass>() { @Override protected void updateItem(MyClassrow, boolean paramBoolean) { if (row != null) { switch (row.getColor()) { case 1: setStyle("-fx-background-color: LIGHTCORAL; -fx-text-background-color: black;"); break; case 2: setStyle("-fx-background-color: skyblue; -fx-text-background-color: black;"); break; default: setStyle(null); } } else { setStyle(null); } super.updateItem(row, paramBoolean); } }); [/SRC] now I need to highlight one cell, the current one, i.e. the one on which the cursor is set. I try to do so
[SRC java] table.setCellFactory((TableColumn<MyClass, Integer> param) -> new TableCell<MyClass, Integer>() { @Override protected void updateItem(Integer item, boolean empty) { if (item != null) { setText(item.toString()); if (table.getSelectionModel().getFocusedIndex() == getTableRow().getIndex()) { setStyle("-fx-background-color: red;"); } else { setStyle(null); } } super.updateItem(item, empty); } }); [/SRC] the highlighting is done, BUT only when opening the table or when the cell I need goes beyond the scope of visibility and comes back (for example, if the list is large and scrolling up / down so that the cell goes beyond the scope)
question: how to force the cell to redraw when changing the selected row?
maybe there are some methods TableView.Repaint or TableView.Update, or any?