aspose file tools
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

Win a copy of Head First Android this week in the Android forum!
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: 869
It is handled by the renderer.

bitguru blog
Rob Spoor

Joined: Oct 27, 2005
Posts: 20039

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
It is sorta covered in the JavaRanch Style Guide.
subject: Different Icons for JTree
It's not a secret anymore!