當我按下抱怨框時,每個輸入對話框顯示兩次...我試圖刪除boxComplain.setSelected(true),它工作(它只顯示一次),但這使複選框去我輸入輸入後。JOptionPane.showInputDialog顯示兩次
class CheckBoxListener implements ItemListener {
public void itemStateChanged(ItemEvent event) {
if(boxComplain.isSelected())
{
ab=JOptionPane.showInputDialog("Enter Reason of Complain: ");
ac=JOptionPane.showInputDialog("Enter What The Complain is About: ");
label4.setText("Complain request");
boxComplain.setSelected(true);
}
}
}
這聽起來像你所註冊的'ActionListener'兩次 – MadProgrammer
沒有我添加了一個checkboxlistener到boxcomplain只有一次我確定 –