JavaFX 2 TableView header font color
Asked Answered
Y

2

6

How can I change the text color of the TableView component's header?

I tired this:

.table-view .column-header, .table-view .filler {
    -fx-text-fill: white;
    -fx-border-width: 0, 0;
    -fx-font-size: 12px;
}

This remove the border, and also change the font size, but not the font color.

Yawata answered 30/12, 2012 at 12:56 Comment(2)
Tried it myself without success. I am pretty sure that your approach is correct, and the color not being set is caused by a bug in JavaFX.Scorpaenid
Thanks for the reply. I tired it a lot ways and quickly ran out of ideas. :S So maybe it's a bug. Thanks for the info!Yawata
K
17

Something like this might work.

.table-view .column-header .label {
    -fx-text-fill: white;
    -fx-font-weight: bold;
}
Kirovograd answered 3/1, 2013 at 3:25 Comment(2)
Thanks a lot! It works like a charm. So the header texts are inside a label. I dodn't tought about that.Yawata
I would really like to style the header of a single column to indicate when something is happening inside of that column that may be out of view and require scrolling. However, there does not appear to be any way to get to a single column header and apply style.Boutique
P
3

@David Charles: style classes of the TableColumn also apply to the column header, so to style an individual column header, you can use

.table-view .column-header.foo .label {
    -fx-text-fill: white;
    -fx-font-weight: bold;
}

and in Java

tableColumn.getStyleClass().add("foo");
Parliament answered 17/2, 2015 at 20:25 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.