Reputation: 101
Is there a way I can make a Do/While statement like this?
do {
JOptionPane.showConfirmDialog(null, "Do you wish to continue?");
} while (answer == yes);
Upvotes: 0
Views: 138
Reputation: 6077
You may change it to:
int answer = JOptionPane.YES_OPTION;
do {
answer = JOptionPane.showConfirmDialog(null, "Do you wish to continue?");
} while (answer == JOptionPane.YES_OPTION);
Upvotes: 0
Reputation: 100
Instead of answer == yes
, you should check if it equals JOptionPane.NO_OPTION
or JOptionPane.YES_OPTION
in your case.
Also, you should be having int answer = JOptionPane.showConfirmDialog(null,"Do you wish to continue?);
Upvotes: 3