File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Node labelling within a tree using depth-first traversal Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Node labelling within a tree using depth-first traversal" Watch "Node labelling within a tree using depth-first traversal" New topic
Author

Node labelling within a tree using depth-first traversal

Adriana Woolley
Greenhorn

Joined: Feb 03, 2006
Posts: 1
Hello,

I'm currently trying to work my way through Java and need some advice on using and traversing trees. I've written a basic JTree program, which allows the user to add and delete nodes. Each new node is labelled in a sequential order and not dependent upon where they are added to the tree.

Basically, what is the best way to add and delete these new nodes with labels that reflect their position in the tree in a depth-first traversal?

ie: the new node's label will correctly reflect its position in the tree and the other labels will change to reflect this addition of a new node.

I've searched Google and can't seem to find any appropriate examples for this case.

My current code is as follows,


Thank you for any help.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Node labelling within a tree using depth-first traversal
 
Similar Threads
JTree ------odd thing
How can i Convert Java JTree Object to XML Format ?? :: Need your valuable suggestions
Same JTree instance across 2 tabs
Jtree adding nodes
how do I get the current node selection in a Jtree?