Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to get the TreePath of a newly inserted TreeNode

 
Kevin Tysen
Ranch Hand
Posts: 255
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


I insert a new node called newProblem into a parent node called selectedNode.
I have the TreePath to the parent node, but I want to know how to get the TreePath to that new node called newProblem.
Anyone know how?
 
Darryl Burke
Bartender
Posts: 5148
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To get better help sooner, post a SSCCE (Short, Self Contained, Compilable and Executable) example that demonstrates the problem.
 
Olivier Legat
Ranch Hand
Posts: 176
Chrome Mac Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Kevin,

Your code doesn't make sense I'm afraid... You're inserting null into the TreeModel. If your newProblem is a DefaultMutableTreeNode then getting the path is easy:

 
Kevin Tysen
Ranch Hand
Posts: 255
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry about not including a whole runnable code.
Anyway, line 8 is what I wanted to know. Thank you!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic