Reputation: 11
I want to take the output of a tar -tf which is a long directory listing for linux filesystem and put it into a java jtree.
The problem I am running into is how to get the hierarchy correct. The root node is easy but how do I add the other nodes to the tree in the proper place? I believe it would involve finding the parent node in the tree.
So far I am using DefaultMutableTreeNode as the root and creating a new one for each node. I created a custom object overriding toString to give the name of the directory or file, a getPath that returns the full path to it and getParent which is the full path without the name on the end.
Upvotes: 1
Views: 162
Reputation: 205785
The article Understanding the TreeModel may offer some guidance on modeling hierarchical files in a TreeModel
suitable for use with JTree
.
Upvotes: 2