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!

ListView Row Color

BluewizardMay 13 2013 — edited May 13 2013
Hi,

I have a LisView with a Cell Factory set. The cell factory changes the text color based on some flags for each row (black, red, green, blue, etc.)

When I select a row I want to change the color of the text to always be WHITE regardless of the original color of the text. This is because some of the text colors (such as red and blue ) don't look good with the default -fx-selection-bar color.

I added the following CSS snippet to my list view.

.list-view:focused .list-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;
}


It works fine, but it doesn't return the text to it's original color when the selection is changed from one row to another.

Is there a proper way to do this?

Thanks.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 10 2013
Added on May 13 2013
1 comment
552 views