我有一个jTable,它被彻底初始化"右键单击>表格内容>绑定>导入数据以形成" ,然后从"右键单击> bind>显示列。元素&#34 ;.我在该表单中也有一个插入表单,我想在插入新行后刷新jTable。我应该怎么做?
答案 0 :(得分:2)
DefaultTableModel model ;
public MyJframe() {
initComponents();
model=new DefaultTableModel();
jTable1.setModel(model);
model.addColumn("DJID");
model.addColumn("DID");
}
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
try {
// Code for inserting to database
model.addRow(new Object[]{DaneshjooID,DarsID});
} catch (Exception e) {
JOptionPane.showMessageDialog(null, "Exception: " + e.getMessage());
}
}