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).
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 ;
}
For JavaFX 8, based on the Modena stylesheet, the selected row text color is based on the brightness of the background (white for dark backgrounds, black for light backgrounds). I've been able to override this by setting the text background color directly (which then gets used for the text color for selected rows):
.table-row-cell:selected {
-fx-background-color: steelblue;
-fx-text-background-color: red;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With