• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Jtree Help

 
Sandeep Jain
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Everyone,
I am stuck with a requiremnt where by I have to show a directory structure in a tree format however the each directory or a file has a unique number with which it is recognised.
Now how do I set a different export value for each node or a directory .
Please help me out as it is very important .
 
Chantal Ackermann
Ranch Hand
Posts: 508
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The MutableTreeNode has the attribute userObject where you can store anything that describes the object represented by the node.
you should write your custom TreeNode (by implementing the appropriate interface (be aware that you have to implement all the listener methods as well) or extending DefaultMutableTreeNode (event/listener are handled in this case but the class is quite complex)). and moreover a custom TreeModel that handles the data (= the nodes). changes made to the data is displayed at once in the JTree and vice versa. see the swing tutorial on TreeModels.
it might sound more difficult than it is, just give it a shot.
cheers
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic