• 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

How to get JTree object of parent node of DefaultMutableTreeNode object?

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Iam trying to get the JTree object from DefaultMutableTreeNode object but iam not getting.Is it possible first..?. i have DefaultMutableTreeNode object, JTree object, TreePath object, TreeModel object of current node. I want to get Parent JTree object of current node. Any one who knows, please help me.

Thanks one and all.
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can't, and the reason is quite simple.

TreeModels and TreeNodes can be shared among many different JTrees, all sharing the exact same data. The same goes for all other models in Swing: TableModel, ListModel, etc. This allows you to have multiple views on the same data.

So for a TreeNode, if you want to get its JTree, the question would be: which one? Unfortunately, the creators of the API didn't think this question was important enough to include methods in the API for it.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic