user777466
user777466

Reputation: 1001

Exit Java application even if a dialog is open

In my application, I use a dialog form:

UtilisateursDialog dialog = new UtilisateursDialog(this,true);
presenter.setUtilisateurActif(dialog.showDialog());

Where UtilisateursDialog is a swing.JDialog.

When the dialog is visible, I noticed that it is impossible to exit the application. In MacOS, a click on application/quit or option+Q do nothing.

Is there a way to make the user able to exit when the dialog is visible?

Upvotes: 2

Views: 189

Answers (2)

Russell Zahniser
Russell Zahniser

Reputation: 16354

If you don't need the dialog to be modal, do presenter.setModal(false) before showing it and the menubar will become functional again.

Upvotes: 2

COD3BOY
COD3BOY

Reputation: 12092

Give a button in dialog with System.exit(0); in its action performed,Terminates the currently running Java Virtual Machine. :)

Upvotes: 2

Related Questions