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

Creating JTree On Run TIme

 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 410
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Its not working :-(

Kinu
 
Stuart Gray
Ranch Hand
Posts: 410
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Doesn't compile or doesn't run? Whats the error or problem you are getting?
 
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic