Sirish V
Sirish V

Reputation: 932

Issue changing table row selection color

Is there a way to modify the row selection color for a specific table?

Right now I have a standard row selection style defined in the style-sheet and applies to all the tables throughout the application.

.table-row-cell:selected {
  -fx-background-color: #777777;
}

However, I have a requirement for one of the tables to display a different highlight color on row select. I had been trying the below but obviously it isn’t working.

In my style-sheet:

 #lightHighlightTable .table-view .table-row-cell:selected {
  -fx-background-color: #CCCCCC;
}

In my code:

recordsTable.setId("lightHighlightTable");

Is there something that I am doing wrong in the above? Any hint on how to achieve this is highly appreciated.

I am using JDK 1.8 b20.

Thanks.

Upvotes: 1

Views: 302

Answers (1)

José Pereda
José Pereda

Reputation: 45456

This will work, since the .table-row-cell style class is applied toTableRow, not to TableView:

#lightHighlightTable .table-row-cell:selected {
    -fx-background-color: #CCCCCC;
}

Upvotes: 2

Related Questions