Reputation: 10078
this function should refresh my JTable:
list = null;
list = (ArrayList<String[]>) interface_engine.getData();
info = new String[list.size()][header.length];
Iterator it = list.iterator();
for (int i = 0; i < list.size(); i++) {
String[] current = (String[]) it.next();
for (int j = 0; j < header.length; j++) {
info[i][j] = current[j];
}
}
DefaultTableModel model = (DefaultTableModel) data_table.getModel();
model.addRow(info);
when i call it for add a new row (getData is a remote method for retrieve data from db), the added row it's not display as a string, but a a variable reference (such as String@128dda...). Where's the problem?
Upvotes: 0
Views: 65
Reputation: 324207
the added row it's not display as a string, but a a variable reference (such as String@128dda...).
Read the DefaultTableModel API. You can't add a 2-Dimensional array using the addRow() method. You can only add one row at a time.
The addRow() method should be inside your loop. Build one row of data, then invoke the addRow() method.
Upvotes: 3