• 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:

JTree question

 
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,
I am building an application that needs to work with some tree-like hierarchical data structure of arbitrary complexity, which will be displayed both as a JTree and as a diagram in the user interface. I was busy trying to think of a way to represent the data I'm working with, but then wondered whether I could scrap that idea and just use JTree to actually hold the data, rather than just represent it on screen?
So, for example, if I create a load of objects of class 'MyEffect', each having properties like name, colour, size, category, can I store these objects in a JTree and use, say, MyEffect.name to label the node?
any advice would be gratefully received.
cheers,
Ben.
 
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am using a JTree for a very complex object and think you should use it. I had to think objectively, I made nodes that handled my data. I then made a TreeModel to handle my nodes and finally a JTree from my TreeModel. I have found all the info is there except for one displaying problem I'm having (I will post it later). Good Luck.
 
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I did something similar : the complex data stuff goes in the user Object for each node.
I find it useful to also keep a HashMap of nodes as they are created - useful for complete-match and partial match searching.
Kate
 
reply
    Bookmark Topic Watch Topic
  • New Topic