JDialog:防止父框架关闭
如何使父框架的焦点无效?我有一个 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使对话框模态。
Make the dialog modal.
您可以使对话框成为模式。有一个实用程序 构造函数 为您执行此操作:
或者您可以在对话框上调用 setModal 函数。
You can make the Dialog modal. There is a utility constructor which does this for you:
or you can call the setModal function on the dialog.