Hi to all, my first post here and hopefully someone can help me with, what I hope, is a small issue.
I am trying to present the results of a select statement in a Jtable but I am only getting the final row of the set appear in the Jtable. The code I have written so far:
String[] columnnames = {
"Category ID",
"Name",
"Category Type"
};
while (result.next()) {
int id = result.getInt("categoryid");
String name = result.getString("name");
String type = result.getString("categorytype");
Object data [][] = {
{new Integer(id),
name,
type
}
};
JFrame frame = new JFrame("Table Printing");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
final JTable table = new JTable(data, columnnames);
JScrollPane scrollPane = new JScrollPane(table);
frame.add(scrollPane, BorderLayout.CENTER);
frame.setSize(300, 150);
frame.setVisible(true);
}
Regards
Tom
Edited by: 846307 on 22-Mar-2011 04:33