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

Displaying data on screen

 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello

I hope this is the right forum to post this question.

How do you display a list of items in a scroll pane after you read them from a database.

e.g. Suppose you have a list of people in a database table called People. The columns are First Name, Middle Name, Last Name, Gender and Date of Birth. I can read the entries from the database into the resultset. But what do I use to display it on the screen.

Suppose I have a business object called People with the fields described above and I create an array of People to hold these values. How can I populate the values of the array from the resultset. Do I have to parse the result and map each value to the appropriate field of a People object and append this object to peopleArray object.

Also what do I use to display this on the screen. I want to have a scrollable list that displays all the People row-wise with column heading for the individual fields.

I suppose there's an easy way to do this but I can't work it out at the moment.

Please help as I am fairly new to this and seem to be running around in circles.

Thanks,
R
 
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

For presentation take a look at JTable. You could populate this with your query results and then add it to a JScrollPane component so it scrolls. One of JTable's constructors takes two Vectors are arguments, one for the data, one for the headers, so you could do something like this to build the Vectors, then pass them into the JTable.



then to populate the table you can do something like



and add jsp to your GUI layout where you want it

hope this helps you get going!
[ September 30, 2004: Message edited by: Ben Wood ]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic