How to change the background color of an element in the tree view?

Hi Communitiy,

I use a ColoredTreeCellRender to render a Tree. Now I would like to change the background color of one of its elements.
I tried to use the setBackground() method, but it does change nothing, that I see. I also experimented with the opaque.

What I'm doing wrong?



Hi Markus,

The SimpleTextAttributes object you pass as a parameter to the append() method has a bgColor attribute. Please make sure that you're setting it correctly.


I set it like this:

SimpleTextAttributes simpleTextAttributes = new SimpleTextAttributes(,, null, SimpleTextAttributes.STYLE_PLAIN);
this.append(psiClass.getName(), simpleTextAttributes);

the result is this:

The PsiClasses that are marked with the JUnit marker should be highlighted with a green background.
I just don't see my mistake. ?:|



Please sign in to leave a comment.