After the user plays a game they get asked wather they want to play again if they selected yes then the game its played and then they are asked again and again until they selected no. When i run the program the dialog box doesnt appear but when i remove s.playGame(); it runs fine. Code for playgame https://www.pastiebin.com/58f937756037a
int dialogButton = JOptionPane.YES_NO_OPTION;
do {
s.playGame();
numberOfGoes++;
JOptionPane.showConfirmDialog(null, "Play again?", "HINT", dialogButton);
if (dialogButton == JOptionPane.NO_OPTION) {
System.exit(0);
}
} while (dialogButton == JOptionPane.YES_OPTION);
JOptionPane.showConfirmDialog(null,"choose one", "choose one", JOptionPane.YES_NO_OPTION);
if (result== JOptionPane.NO_OPTION) {
System.exit(0);
}
Here is minimal testable exmaple for you
public static void main(String[] args) {
int result = JOptionPane.showConfirmDialog(null, "Play again?", "HINT", JOptionPane.YES_NO_OPTION);
if (result == JOptionPane.NO_OPTION) {
System.out.println("No chosen");
}
if (result == JOptionPane.YES_OPTION) {
System.out.println("Picked YES");
}
}
Adapt it to suit your needs