Hi, There, I need to recursively call SQL to retrieve data which have inhert relationships. Then display the data into JTree. I don't need the tree to be balanced or ordered, but definitely not binary. And the JTree need to be manipulated a lot while keeping the hierarchy of the tree. Does anyone have recommendation on what Data Structure I should use to store the data returned from Database? Or should I just write my own tree structure? Thanks a lot!! Nina
I did a lot with JTrees and at least for me it was enough to extend form DefaultTreeModel and to fill the model with DefaultMutableTreeNodes. The DefaultMutableTreeNode has an UserObject. There you can put in any Object, you need. It should simply implement a toString method for displaying. I think, this is the reason, why DefaultMutableTreeNodes are a good choice.
Joined: Jun 26, 2002
Thanks Rene! Because I need to display the tree first. Then allow people to select leaves into a list, although the list is a flat one, I still need to keep the integrity of the original tree structure within the list by validating the leaves every time people choose them. Have you ever done this kind of things? Do you think the treeModel is enough to do that? Thanks! Nina