Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

TableView: How to set row background color & text color with CSS

963802Apr 16 2013
I am having trouble setting the background color of the rows in a TableView and also setting the text color using CSS. I would like the following

* CSS for setting the row color (both odd and even)
* CSS for setting the font color for the rows
* CSS for setting the selected row's background color & font

This code doesn't seem to work...
.table-row-cell {
    -fx-background-color: black;
    -fx-background-insets: 0, 0 0 1 0;
    -fx-text-fill: white;
}
.table-row-cell:odd {
    -fx-background-color: -fx-table-cell-border-color, derive(-fx-control-inner-background,-5%);
    -fx-background-insets: 0, 0 0 1 0;
    -fx-text-fill: white;
}
I found this css below which seems to work for the selected row. Is this correct?
.table-view:focused .table-row-cell:filled:focused:selected {
    -fx-background-color: -fx-focus-color, -fx-cell-focus-inner-border, -fx-selection-bar;
    -fx-background-insets: 0, 1, 2;
    -fx-background: -fx-accent;
    -fx-text-fill: -fx-selection-bar-text;
}
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 14 2013
Added on Apr 16 2013
0 comments
838 views