确认后,Java弹出菜单会弹出多次

时间:2017-06-10 12:42:43

标签: java popupmenu

当用户按下重置按钮重置高分时,我正在尝试确认。当用户按下它时,它会询问他们是否确定然后确认,一旦确认它再次弹出。

         rH.addActionListener((ActionEvent e) -> {

        int dialogButton5
                = JOptionPane.showConfirmDialog(this, "Are you sure you wish to reset leaderboard?", "Leaderboard", JOptionPane.YES_NO_OPTION);

        if (dialogButton5 == JOptionPane.YES_OPTION) {
            System.out.println("");
            hScore = 0;
            Hname = " ";
            highScore.setText("High Score: " + hScore + " Name: " + Hname);

        } else if (dialogButton5 == JOptionPane.NO_OPTION) {

        }
    });

0 个答案:

没有答案