This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js and have Paul Jensen on-line!
See this thread for details.
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

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

 
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: 21044
85
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!