I'm trying to populate my DefaultTableModel by first taking a populated List collection and then converting them to an array of Object.
The problem begins when I addRow(Object[])
into DefaultTableModel. It always comes up empty. To be more precise, the DefaultTableModel is populated with rows, but the rows are empty, no columns or anything.
My main objective is to eventually put the contents of the List in DefaultTableModel to be able to put that in a JTable using setModel()
.
Source code:
List<Inventory> list = app.dao.getInventoryList(false, 0);
Object[] o = null;
for (Inventory i : list) {
o = new Object[6];
o[0] = i.getID();
o[1] = i.getGoodName();
o[2] = i.getCreateTime();
o[3] = i.getCreateUser();
o[4] = i.getUpdateTime();
o[5] = i.getUpdateUser();
app.dtInventory.addRow(o);
}
app.inventoryTableView.setModel(app.dtInventory);