Dynamically adding icons to JTree for the selected node

gpalanivel
gpalanivel used Ask the Experts™
on
Hi,

 I have created aTree using Jtree.  Now I want to append icons dynamically to the selected node.
.

Eg:
 
„h RootNode
    „h First Child Node
    „h SecondChild Node „h „h...„h

In the above tree, "Second Child Node"  node is selected and n number of icons are to be added after the Highlighted text.
Can anyone give me suitable solution for this. If possible send me sample code.

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Java Developer
Top Expert 2010
Commented:
You'll need to define your own custom cell renderer for that.

There's are example here using custom renderers:
http://www2.gol.com/users/tame/swing/examples/JTreeExamples2.html

to get multiple icons try using a panel with multiple JLabel (with icon and no text), one for each icon required.
Alternately you could build a single icon by concatenating the ones you require.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial