user2748531
user2748531

Reputation: 1443

javafx table row doesn't change color

In my program I have this on the css file:

.error-row {
    -fx-text-fill: red;
}

If the row in a table view is an error, it's text should be red. If is an error, I do getStyleClass().add("error-row"); in the factory, but it doesn't work. If I add things like background color and font weight int the css .error-row, they work, but not the color. Anyone knows why?

Upvotes: 1

Views: 1236

Answers (1)

James_D
James_D

Reputation: 209359

I'm guessing that you are using a rowFactory on the TableView. The default css stylesheet defines the text fill on the table cell, which is a descendant of the table row, and so the default value overrides the value you set on the row.

Try

.error-row .table-cell {
    -fx-text-fill: red ;
}

Upvotes: 2

Related Questions