5

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

Screenshot of what I want to change

Miss Chanandler Bong
  • 4,081
  • 10
  • 26
  • 36
Tule Simon
  • 111
  • 6
  • 1
    Well 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 Answers1

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