Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Make a color to jtree  RSS feed

 
swarna latha
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

How to make color to specific node in jtree.

I have used tree renderer its not working.

If any body knows the solution please tel me.

Thanks and regards
K.Swarna Latha
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by swarna latha:
Hi,

I have used tree renderer its not working.


If your renderer returns a label type object, you need to call setOpaque(true) explicitly. Labels by default are set to false i.e. they are transperant.

If this doesnt work, can you post the renderer code?
 
swarna latha
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Thanks for the reply.

But if i use setOpaque(true) its not getting color as wel as i cant able to

select elements in JTree.

Thanks and regards
Swarna
 
Rob Spoor
Sheriff
Posts: 20893
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can't select elements, or you just can't see you have selected them?

Remember, if you set the background of the renderer, you will always see that color. Instead, in your renderer, you should use a different color (hint: use UIManager.getColor("Tree.dropCellBackground") and/or getBackgroundSelectionColor()) when the node is selected.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!