1

I have created Jtree with Root node and 4Subnodes.
My problem is like this:

  • I need to change the foreground and background color of a particular node dynamically.

How can i do it?
Help me with some piece of code.

Thank you all in advance...

svkvvenky
  • 1,122
  • 1
  • 15
  • 21

2 Answers2

1

How can i do it?

I'm sure that JTree tutorial contains valuable info about DefaultTreeCellRenderer,

Help me with some piece of code.

tons of examples here or here or here

Community
  • 1
  • 1
mKorbel
  • 109,525
  • 20
  • 134
  • 319
  • 1
    It's the right approach; you can change the icon, too, as shown [here](http://stackoverflow.com/a/8351850/230513). – trashgod Jan 01 '12 at 00:20
0

One easy way I found was to include HTML markup in the node text. The renderer (Windows 7, Java7.45) respects font color changes. Low-rent but gets the job done!

ConorR
  • 477
  • 5
  • 9