In the do while
loop it checks if the user inputs any letters or 0
an that works well but when i click on the cancel
button in the JOptionPane
it enters the loop again instead of exiting theJOptionPane
do {
try {
op = JOptionPane.showInputDialog(null, "How Many Elements do you want in the universe?");
opi = Integer.parseInt(op);
if (op.equals("0")) {
JOptionPane.showMessageDialog(null, "The Universe cannot be empty");
try_Error = false;
} else {
try_Error = true;
}
} catch (Exception e) {
JOptionPane.showMessageDialog(null, "Enter Numbers Only");
try_Error = false;
}
} while (!try_Error);