• Post Reply Bookmark Topic Watch Topic
  • New Topic

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

 
sridhar bvap
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • 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.
 
Rob Spoor
Sheriff
Posts: 20817
68
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!