暂停执行,直到关闭子对话框 [英] Pause execution until the child dialog is closed

查看:61
本文介绍了暂停执行,直到关闭子对话框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从JFrame打开JDialog.我想暂停执行,直到关闭子对话框,但是主框架正在连续执行而没有任何暂停.我正在使用以下代码.

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.

什么是替代解决方案?

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.

推荐答案

确保NewDialogJDialog扩展并且设置为模式(setModal(true)).您可能想看看如何使用对话框

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

这篇关于暂停执行,直到关闭子对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆