• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JTree data from database

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

I'm working on the example at http://java.sun.com/docs/books/tutorial/uiswing/examples/components/GenealogyExampleProject/src/components/GenealogyExample.java

I wanted to customize it in a way the data are pulled from a table instead (folder_id, folder_name, parent_id[foreign key to determine parent] .
Here is my code


If I hardcode it as Person a1 = new Person("Jack (great-granddaddy)"); , it works fine. However, I wanted to put it in a loop, with the variable i :-

How can I make the variable i and the "a" to be combined together? In PHP, we usually combine them with a "." , eg "a".$i;

Thanks Any other example on creating trees from database is greatly appreciated too. Thanks in advance
 
Marshal
Posts: 28177
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So you want an array of Person objects? You already used an array in the line just above that, so it looks like you might already have some idea about arrays.
 
Wynn Teoh
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Thanks for your reply. I roughly work on the array from some examples. Don't really know if I'm doing it correctly

Do you mean that the Person objects have to be in array, and not in a loop like what I;m doing now? I want to have the variable "a1","a2","a3"... dynamically. Is it possible?
Thank you!
 
Wynn Teoh
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just to add in more info, the example given looks somehting like this :



Then the trees will be in a hierarchy
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic