This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes Identify the path of the node and insert in JTree. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Identify the path of the node and insert in JTree." Watch "Identify the path of the node and insert in JTree." New topic
Author

Identify the path of the node and insert in JTree.

Melki Joe
Greenhorn

Joined: Aug 29, 2008
Posts: 24
I am having two trees and I want to get the node from one tree and insert it into another tree. While inserting if the source node has more parents how to identify the path of the node and insert into the appropriate node in the destination tree.

Kindly help me in this issue.
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

How do you want to indicate what node to copy and where to move it to? What does "more parents" mean? That the node is more than 1 layer deep in the tree? Why does this matter? Are you trying to copy the node itself or the node and the path to it? Or do you need to insert the node at the same level in the new location?


-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
Melki Joe
Greenhorn

Joined: Aug 29, 2008
Posts: 24
I need to insert the node at the same level in the new location.

Here I am giving the structure for more parents.

A
-1
--2
---leaf1
---leaf2
B
-1
--2
---leaf1
---leaf2
---leaf3

I want to transfer the leaf nodes as if the left tree to the right tree.
 
wood burning stoves
 
subject: Identify the path of the node and insert in JTree.
 
Similar Threads
Problems with Drag and Drop
Create an object?
how to add a new node to already existing node but i dont know the parent node
jtree not scrolling to selected node
Algorithm to find Nodes having largest distance in Binary tree.