Re: Converting Tree Structure from Vector
- From: Roedy Green <my_email_is_posted_on_my_website@xxxxxxxxxxxxxx>
- Date: Mon, 17 Oct 2005 00:43:12 GMT
On 16 Oct 2005 12:39:53 -0700, paul.sharivker@xxxxxxxxx wrote or
quoted :
>I need to create a structure which will be loaded on JSP page and will
>have select boxes for parent->child->child->child.
>I was thinking to load the data into 4 Array List but dont know how the
>values will be related if user select a child and which child to load.
>Do you have any ideas?
You could invent a Node class that points to a parent with perhaps an
ArrayList of children. It would also have an id field and a name
field.
Put them in a HashMap indexed by id.
Then loop through i .. n looking at your Vector triples and doing the
obvious things to hook up parents and children.
After the tree is built, you might consider replacing each ArrayList
with an array.
To display the tree graphically, look into JTree.
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.
.
- Follow-Ups:
- Re: Converting Tree Structure from Vector
- From: paul . sharivker
- Re: Converting Tree Structure from Vector
- References:
- Converting Tree Structure from Vector
- From: paul . sharivker
- Converting Tree Structure from Vector
- Prev by Date: Re: JSP commenting help needed, please!
- Next by Date: Re: JSP commenting help needed, please!
- Previous by thread: Converting Tree Structure from Vector
- Next by thread: Re: Converting Tree Structure from Vector
- Index(es):
Relevant Pages
|