JDialog关闭图标查询?
我想删除 JDialog
选项中存在的关闭图标。我怎样才能实现这一目标?
要求:尝试通过删除“x”或关闭图标来重新设计默认对话框结构,
提前谢谢您。
I would like remove the close icon present in the JDialog
Option. How can I Achieve this?
Requirement: Trying to re-design the default Dialog Structure by removing the 'x' or close icon
Thank You in Advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您无法删除它(并保留标题栏),但您可以使用以下方法禁用其功能:
You can't remove it (and keep the title bar) but you can disable its functionality by using:
dialog.setUndecorated(true);
应该为您执行此操作(从 java.awt.Dialog 类),但有一些问题,最值得注意的是此方法也会删除标题栏,使得对话框无法在屏幕上移动。此此问题/答案了解更多信息。
dialog.setUndecorated(true);
should do it for you (a method inherited from the java.awt.Dialog class), but there are some catches, most notably that this method will also remove the title bar, making it impossible to move the dialog around the screen.This this question/answer for more information.
如果您想要执行一些额外的操作,那么总是最好重写 setDefaultCloseOperation 方法。然而你无法阻止对话框关闭。我尝试过,但无法阻止它关闭。但是,是的,通过覆盖 setDefaultcloseoperation 方法,我能够执行一些列表清理和文件关闭操作。
尝试按如下方式重写该函数。
IT is always beeter to override the setDefaultCloseOperation method if you want to perform some extra operations. How ever you can not stop the dialog from getting closed. I tried but was not able to stop it from closing. But yes by overiding the setDefaultcloseoperation method i was able to perform some list cleanup and file closing operations.
Try to override the function as follows.