问题
I am trying to open a JDialog
from JFrame
. I want to pause the execution until the child dialog is being closed, but the main frame is being executed continuously without any pause. I am using the following code.
What is alternate solution?
Class NewFrame extends JFrame
NewFrame()
try
{
NewDialog frm = new NewDialog();
frm.show();
JOptionPane.showMessageDialog(null,"yes");
}
catch(Exception ex)
{
ex.printStackTrace();
}
}
}
In the above program I want a message should be displayed when the dialog box should be closed.
回答1:
Make sure that NewDialog
is extend from JDialog
and is set to modal (setModal(true)
). You might like to take a look at How to use Dialogs
来源:https://stackoverflow.com/questions/14292071/pause-execution-until-the-child-dialog-is-closed