[英]How do you add data to a new row in a java swing table?
I have created a new table row with the below code, however I am having trouble populating that row with data.我用下面的代码创建了一个新的表格行,但是我无法用数据填充该行。 How would one go about adding data to the new table row?
如何将数据添加到新表行?
DefaultTableModel model = (DefaultTableModel) this.jTable1.getModel();
Object[] row = new Object[4];
Got outside help - here's the solution for posterity;得到外部帮助 - 这是后代的解决方案;
DefaultTableModel model = (DefaultTableModel)
this.jTable1.getModel();
Object[] row = new Object[4];
row[0] = newUser;
row[1] = newPass;
row[2] = newDept;
row[3] = newTel;
model.addRow(row);
Note: Replace variables with what you want.注意:用你想要的替换变量。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.