-1
I have an example:
Object rowData[][] = { { "Row1-Column1", "Row1-Column2", "Row1-Column3" },{ "Row2-Column1", "Row2-Column2", "Row2-Column3" } };
Object columnNames[] = { "Posição", "Nome", "Pontuação" };
JTable table = new JTable(rowData, columnNames);
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JScrollPane scrollPane = new JScrollPane(table);
frame.add(scrollPane, BorderLayout.CENTER);
frame.setSize(255, 400);
frame.setVisible(true);
I need to do the rowData
receive a ResultSet
, I don’t master java, and so far while
I couldn’t do the rowData
receive my ResultSet
if(rs != null) {
while(rs.next()) {
// rowData = ??
}
}
want to get the data that are in
jtabel
?– jsantos1991
no, I want rowData to receive my rs @jsantos1991
– Dexxtz
try this:
DefaultTableModel tm = (DefaultTableModel) table.getModel();
then use thetm
to insert type:tm.addRow(new Object[]{new String("aaaaa"), new String("bbbb"), new String("ccccc"), new String("ddddd")});
– jsantos1991