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 ?
Set the background color on the cells:
.myTree .tree-cell {
-fx-background-color: #0a0a0a ;
-fx-text-fill: #ffffff ;
}
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With