How to change the project tree selection colour?

I would like to change the selection colour of the project tree, and I made it as far as this snippet:

UIManager.put("Tree.selectionBackground", new Color(54, 54, 54));


However, this only changes the colour when the file tree is also in focus, when I go back to the actual editor the colour changes back to the default selection colour. Is there any way to change the unfocused selection colour as well?

Also, and this is more of a side question, is it possible to hook into the cell rendering itself? For example give it a custom text colour, but without having to override the default cell renderer? It seems there should be a way for this since the VCS systems is able to do it, but I can't find an appropriate extension point anyway.

1 comment
Comment actions Permalink

Alrighty, so, the UIUtil class has a method called getTreeUnfocusedSelectionBackground() which returns the color to be used. Only downside is that it uses a hard coded colour when the dark theme is used, so my trick is to replace "Tree.textBackground" with white, but full transparency, which forces the UIUtil to go down the light code path which returns the static value of UNFOCUSED_SELECTION_COLOR and that I can just replace by using Javas reflection API to access the fields and then changing the value.

Is this a total hack? Hell yes it is! But I really don't care, software is supposed to do what I tell it to do.

0

Please sign in to leave a comment.