• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Jtree Help

 
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 .
 
Ranch Hand
Posts: 508
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
You can't expect to wield supreme executive power just because
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic