每次我从我的JButton中删除一些东西,它会在数据库中删除,但我的jpanel不会更新... 我想知道是否有一个简单的解决方法吗?
private void DeleteActionPerformed(java.awt.event.ActionEvent evt) {
infLabel.setText(inform[2]);
Connection connection = FlatFinder.getConnection();
Statement selectStmt = null;
try {
selectStmt = connection.createStatement();
Flat activeFlat = (Flat) AdminAll.getSelectedValue();
String sql = String.format(
"DELETE FROM `flats` WHERE flat_id = %d",
activeFlat.getId()
);
selectStmt.executeUpdate(sql);
} catch (SQLException ex) {
Logger.getLogger(MainPanel.class.getName()).log(Level.SEVERE, null, ex);
}
this.repaint();
}
这是我目前的代码。当我按下删除按钮时,是否有任何简单的解决方案来更新jpanel?