aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Creating JTree On Run TIme Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Creating JTree On Run TIme" Watch "Creating JTree On Run TIme" New topic
Author

Creating JTree On Run TIme

Kinu Kanwar
Ranch Hand

Joined: Apr 19, 2005
Posts: 33
I have a data in this form

int node [] = 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8
int parent[] = -1 , 0 , 0 , 1 , 1 , 3 , 3 , 2 , 2

For example

node[A] = X
parent[A] = parent of X

and I ahve to draw Tree depending on relation b/w two arrays .... Any help is appreciated ...

Regards

Kinu Kanwar
Stuart Gray
Ranch Hand

Joined: Apr 21, 2005
Posts: 410
I think something like this should work:




Here is some Java code (I haven't tested it though):

This assumes that nodes is an array of TreeNodes, which you could achieve like this:
Kinu Kanwar
Ranch Hand

Joined: Apr 19, 2005
Posts: 33
Its not working :-(

Kinu
Stuart Gray
Ranch Hand

Joined: Apr 21, 2005
Posts: 410
Doesn't compile or doesn't run? Whats the error or problem you are getting?
Craig Wood
Ranch Hand

Joined: Jan 14, 2004
Posts: 1535
 
wood burning stoves
 
subject: Creating JTree On Run TIme