0
addListSelectionListener 내에 확인 대화 상자가 있습니다. 테이블에서 행을 선택하면이 호출됩니다. 그런 다음 확인 대화 상자가 나타나고 예 또는 아니요를 클릭하면 계속 나타납니다.대화 상자가 여러 번 표시되는지 확인
이것은 내 코드입니다.
public Reference() {
initComponents();
fillTable();
jTable1.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
public void valueChanged(ListSelectionEvent e) {
int prompt = JOptionPane.showConfirmDialog(null, "Are you sure you want to Check Out this item?", "Warning", JOptionPane.YES_NO_OPTION);
if (prompt == 0) {
String accessNo = jTable1.getValueAt(jTable1.getSelectedRow(), 0).toString();
String query = "delete from reference where accessNo=" + accessNo + "";
if (DB.executeNonQuery(query) > 0) {
JOptionPane.showMessageDialog(null, "Check out Successfull!");
fillTable();
} else {
JOptionPane.showMessageDialog(null, "Check out Failed!");
}
}
}
});
}