Reputation: 351
How can I stop dialog box running?
String menuInput = null;
JOptionPane askOpenOrNew = new JOptionPane(
"Would you like to Open a save\nor create a New world?");
Object[] askOptions = new String[] { "Open World", "New World",
"Cancel" };
askOpenOrNew.setOptions(askOptions);
JDialog askDialog = askOpenOrNew.createDialog(new JFrame(),
"There is no World");
askDialog.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
askDialog.setVisible(true);
It keeps the console in Eclipse running after the program, should have, terminated.
EDIT: The dialog box does close (In that it disappears from screen) but the console doesn't terminate unless explicitly told (System.exit(0)).
Upvotes: 0
Views: 164
Reputation: 10714
If you want the program to exit, I'd recommend explicitly calling System.exit(0)
Upvotes: 1
Reputation: 7109
If you want the program to exit after you close the dialog box, you replace
askDialog.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
With
askDialog.setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
I hope this is what you're looking for.
Upvotes: 0