JDialog:防止父框架关闭

发布于 2025-01-07 13:13:46 字数 311 浏览 3 评论 0原文

如何使父框架的焦点无效?我有一个 JFrame (parentFrame),我打开一个 JDialog 如下:

JDialog dialog = new JDialog(parentFrame);

现在我需要设置对话框,这样,每当尝试有人单击父框架时,它总是将焦点放在该对话框上,甚至阻止父框架关闭。

例如,当您在 Windows 中添加环境变量时(系统属性 -> 高级选项卡 -> 环境变量按钮单击),环境变量窗口阻止其父窗口关闭。

How can invalidate focus from parent frame? I have a JFrame (parentFrame), and I am opening a JDialog as:

JDialog dialog = new JDialog(parentFrame);

Now I need to set the dialog is such a way that, whenever trying someone click the parent frame it always put focus on that dialog, even resist the parent frame to be closed.

As an example, while you are adding an Environmental Variable in Windows (System Properties->Advanced Tab->Environmental Variables button click), the Environmental Variable window resist its parent to be close.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

阿楠 2025-01-14 13:13:46

使对话框模态

Make the dialog modal.

纸短情长 2025-01-14 13:13:46

您可以使对话框成为模式。有一个实用程序 构造函数 为您执行此操作:

JDialog(parent, title, modal);

或者您可以在对话框上调用 setModal 函数。

You can make the Dialog modal. There is a utility constructor which does this for you:

JDialog(parent, title, modal);

or you can call the setModal function on the dialog.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文