Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java: How can I disable clicking on a panel while showing dialog?

I want to disable clicking on the background panel or frame while showing a dialogue. And I want the dialogue to appear on top of this panel or frame constantly until it is closed.

Enter image description here

How can I do this?

like image 210
Olcay Ertaş Avatar asked Sep 29 '11 09:09

Olcay Ertaş


2 Answers

Make Dialog/JDialog modal by calling dialog.setModal(true);. This will solve both issues of clicking background panel and remaining on top of panel.


It seems like this method is obsolete so better you should use dialog.setModalityType(Dialog.ModalityType type)

like image 156
Harry Joy Avatar answered Oct 13 '22 11:10

Harry Joy


You can use JOptionPane for the message dialog.

like image 31
Eng.Fouad Avatar answered Oct 13 '22 11:10

Eng.Fouad