How to change the colors of the TableView's rows?
javafx-2
Solution
/* Selected row */
.table-view:focused .table-row-cell:filled:focused:selected {
-fx-background-color: brown;
-fx-background-insets: 0, 1, 2;
-fx-background: -fx-accent;
-fx-text-fill: -fx-selection-bar-text;
}
/* Selected row when table not focused */
.table-row-cell:filled:focused:selected {
-fx-background-color: red;
-fx-background-insets: 0, 1, 2;
-fx-background: -fx-accent;
-fx-text-fill: -fx-selection-bar-text;
}
/* Row hovered */
.table-view:row-selection .table-row-cell:filled:hover {
-fx-background-color: green;
-fx-background-insets: 0, 0 0 1 0;
-fx-text-fill: -fx-text-inner-color;
}
/* Selected row hovered */
.table-view:focused .table-row-cell:filled:focused:selected:hover {
-fx-background: -fx-accent;
-fx-background-color: yellow;
-fx-background-insets: 0, 1, 2;
-fx-text-fill: -fx-selection-bar-text;
}
/* Selected row hovered when table not focused */
.table-view:row-selection .table-row-cell:filled:focused:hover {
-fx-background-color: blue;
-fx-background-insets: 0, 0 0 1 0, 1 1 2 1, 2 2 3 2, 3 3 4 3;
-fx-text-fill: -fx-text-inner-color;
}
Problem
I have a tableview and want to change the default colors of the rows if I... 1. ... hover above a row. 2. ... selected a row. Is there a easy way to do all of it in the css-file? All I found out is that for case 1, I can set `.table-cell:hover { -fx-background-color: green; }` in the css-file. With that the color of the cell changes but not the color of the whole row. `.table-view .row-selection:hover{ -fx-background-color: lightgreen; }` and a lot of other combinations I tried are not working.