Java – How to use CSS styling for Java FX List View?

I have a list view inside a grid pane in the middle of the border pane inside a Java FX tab. When I try to use the CSS below to style the list view, it does nothing.

.list-view .list-cell:even {
    -fx-background-color: blue;
    -fx-text-fill: pink;
}

.list-view .list-cell:odd {
    -fx-background-color: red;
    -fx-text-fill: white;
}

 .list-view .list-cell:even:hover  {
    -fx-background-color: green;
    -fx-text-fill: black;
}

.list-view .list-cell:odd:hover  {
    -fx-background-color: green;
    -fx-text-fill: black;
}

Although if I only use:

.list-view {
    -fx-background-color: blue;
}

It makes a difference and turns the background blue. How do I get the first set of code to work on styling cell elements / What am I doing wrong? I am using Java FX8.

Leave a Reply

Your email address will not be published.