Is there any way to change the color of a selected TreeView
item, instead of the default red and blue color that shows when a TreeItem
is selected
Asked
Active
Viewed 347 times
5

Miss Chanandler Bong
- 4,081
- 10
- 26
- 36

Tule Simon
- 111
- 6
-
1Well that red line is already non-standard. What library are you using? Anyway, you probably just need to set a different background. For instance, with CSS it may look something like: `.tree-cell:selected { -fx-background-color: XXX; }`. If whatever library you're using uses a border for that red line you'll have to change the border color as well. – Slaw Jan 24 '20 at 09:14
-
The red looks like -fx-border-left-color, but probably you already looked into that. – Joop Eggen Jan 24 '20 at 09:25
-
@Slaw That's correct, this is `JFXTreeView` from the `JFoenix` library – Miss Chanandler Bong Jan 24 '20 at 10:12
1 Answers
6
This is not a standard java TreeView
, I noticed that you're using JFoenix
's tree view JFXTreeView
. You can change the color of this selection bar by applying:
.tree-cell .selection-bar {
-fx-background-color: green;
}
To change that background color:
.tree-cell:selected {
-fx-background-color: green;
}

Miss Chanandler Bong
- 4,081
- 10
- 26
- 36
-
That works but what about the blue color background of the treeitem that appears when its clicked, how do i change that color – Tule Simon Jan 24 '20 at 11:25
-
@TuleSimon you can change it using: `.tree-cell:selected { -fx-background-color: green; }` – Miss Chanandler Bong Jan 24 '20 at 12:55