Reputation: 191
This seems like something crazy simple, I'm new with JavaFX, and I cannot change the background and text color of JavaFX TreeView (added inside of a GridPane). Ive initialized the treeview constructor with the root node of populated treeitem.
in the .css:
.myTree {
-fx-font: 12px Tahoma;
-fx-stroke: #eeeeee;
-fx-background-color: #0a0a0a;
-fx-text-fill: #ffffff;
}
and in the code
treeView.getStyleClass().add("myTree");
the font sets, but nothing else. I cant seem to find any example of anyone changing the background of treeview - lots of doing fancy changes on select and hover. Any ideas ?
Upvotes: 6
Views: 12628
Reputation: 41
If you just want a simple way to get away from the yucky white tree background color, you can do this in the scene builder.
Upvotes: 1
Reputation: 209339
Set the background color on the cells:
.myTree .tree-cell {
-fx-background-color: #0a0a0a ;
-fx-text-fill: #ffffff ;
}
Upvotes: 10