File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes Different Icons for JTree Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Different Icons for JTree" Watch "Different Icons for JTree" New topic

Different Icons for JTree

Pat Peg
Ranch Hand

Joined: Feb 04, 2005
Posts: 195
I know that i can generally replace idons in a jtree for leaves, open, closed etc. but can I have specific icons for specific nodes/leaves? In otherwords, is it possible that in a large tree each item could be graphically represented in a different way (not just the three basic ways that are given)? An example might be an athletic association where they would want to represent each team on the 'tree' by their mascot. If possible, how would you do this. Can this be set in the node or is it set in the tree?
Brian Cole
Ranch Hand

Joined: Sep 20, 2005
Posts: 878
It is handled by the renderer.

bitguru blog
Rob Spoor

Joined: Oct 27, 2005
Posts: 20275

Originally posted by Brian Cole:
It is handled by the renderer.

I'd modify the body just slightly:

Because you are now assuming behaviour (the return this part) that might someday change.

How To Ask Questions How To Answer Questions
I agree. Here's the link:
subject: Different Icons for JTree
It's not a secret anymore!