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.
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