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.
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.
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