• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Data Structure for display in JTree?

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Nina Wang
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic