英文:
How do you add data to a new row in a java swing table?
问题
我已经使用以下代码创建了一个新的表格行,但是我在向该行填充数据时遇到了问题。有什么方法可以向新的表格行添加数据呢?
DefaultTableModel model = (DefaultTableModel) this.jTable1.getModel();
Object[] row = new Object[4];
英文:
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];
答案1
得分: 0
得到外部帮助 - 这里是为了后人记录的解决方案;
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);
注意:将变量替换为您所需的内容。
英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论