Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

building JTree from list

 
Rob Byrd
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a list of objects A,B,C,D,E,F,G,H and want to build a JTree by iterating through the list, making A,B,and C children of the root, making D and E children of C, and making F, G, and H children of the root. Can someone tell me how to do this? Thanks in advance.
 
Rob Spoor
Sheriff
Posts: 20822
68
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why are D and E children of C, and are all others children of the root node? If you can't tell us this, I see little choice but to hard code the tree structure.
 
Rob Byrd
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Objects in the list represent actions to be executed, one at a time, as the user steps through the list. Object C represents a special object that signals the beginning of a Group, whose children (D, E) are automatically executed sequentially without the user having to step through them individually. Object F signals the end of the group, after which other objects may appear (G, H). I wanted D and E to be indented in the JTree to make it easier for the user to see the grouping. Ultimately I anticipate nested groups, but I wanted to start with something simple that I could understand.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!