Pause execution until the child dialog is closed

时光总嘲笑我的痴心妄想 提交于 2019-12-24 05:54:28

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!