当用户按下重置按钮重置高分时,我正在尝试确认。当用户按下它时,它会询问他们是否确定然后确认,一旦确认它再次弹出。
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) {
}
});