javafx - How to set selected row text color in not focused TableView

css, javafx-2

Solution

This works for me, though there may be easier ways:

.table-row-cell:selected {
   -fx-background-color: steelblue; 
}
.table-row-cell:selected .text {
       -fx-fill: red ;

}

Problem

My app uses row selection mode (`table.setCellSelectionEnabled(false)`) In my CSS: ``` .table-row-cell:selected { -fx-background-color: steelblue; -fx-text-fill: red !important; } ``` property `-fx-background-color` works fine, but `-fx-text-fill` does not. The text color of selected row is black (if `TableView` is not focused) or white (if `TableView` is focused).

Original source