How can I make my application pause when I open custom JDialog and after the dialog is closed to make continue again.
+9
A:
Simply use:
setModal(true);
I usually call it from within the constructor of the JDialog
.
See the Javadocs on setModal(boolean)
.
http://java.sun.com/javase/6/docs/api/java/awt/Dialog.html#setModal(boolean)
That will cause execution to block on the current thread until the dialog box closes.
Alternatively, you can use:
setModalityType(Dialog.DEFAULT_MODALITY_TYPE);
It is equivalent to setModal(true)
and technically the correct way to do it.
jjnguy
2009-05-29 18:14:22
+1
A:
See the constructor of JDialog http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/JDialog.html#JDialog(java.awt.Dialog,%20java.lang.String,%20boolean) . You can set the modality of this dialog. Setting modal=true will pause your application. you can also use the method 'setModal' http://java.sun.com/j2se/1.4.2/docs/api/java/awt/Dialog.html#setModal(boolean)
Pierre
2009-05-29 18:16:35