Initialy I am creating a JTree with the data obtained from model. While creating the tree, I store the node information in a Map. Later,I am trying to create a JTree using the data from Map which was populated while creating the tree initially. but, since the parent-child relationship is already set up, the tree is not getting created. It just show the root node (root is shown because I am doing -> rootNode.setUserObject(data)). When I get the next avlue from Map and do insert(), it does not show up on the tree. Can some one please tell me how to create tree from the tree data stored in Map? Not able to figure out for the past 2 days.
I'm not clear on how the tree data is set up in the Map... A Map has keys and entries, what type of data are in the keys? What type of data are in the entries? Maps are also un-ordered, so how do you know where the data goes in the tree?
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
I understand that you want to convert the tree to a map to store it and reuse it later. Why aren't you using Serialization for this? That is it's purpose. You would have to create an ObjectOutputStream, serialize the tree (store it on disc), and whenever you need it, you would create an ObjectInputStream and deserialize it. see: http://java.sun.com/docs/books/tutorial/essential/io/serialization.html Chantal
posted 17 years ago
Thanks for he reply. I was able to solve the problem myself. I was storing the node id as key and the node itself as the value in Map. To recreate the tree I used temporary Map along with the original Map key-values.
Please do not shoot the fish in this barrel. But you can shoot at this tiny ad:
Two software engineers solve most of the world's problems in one K&R sized book