我已经使用了 fireDataChanged 方法,但我认为由于它连接到我的数据库,它不会做任何事情。
DelBtn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
int selRow = table.getSelectedRow();
Object element = table.getValueAt(selRow, 0);
th = table.getTableHeader();
tcm = th.getColumnModel();
Statement statement = null;
try {
statement = ResultSetTableModelFactory.connection
.createStatement();
if (JisSelected == true) {
String delete = "DELETE FROM J WHERE JNO = '" + element + "';";
statement.executeUpdate(delete);
}
if (SPJisSelected == true) {
String delete = "DELETE FROM SPJ WHERE SNO = '" + element + "';";
statement.executeUpdate(delete);
}
System.out.println(element);
} catch (Exception ex) {
//ex.printStackTrace();
}
model.fireTableDataChanged();
}
});
}