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?

Markus

2 comments

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.

0

I set it like this:

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


the result is this:
TreeView.jpg

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

Markus

0

Please sign in to leave a comment.