[英]Java: How can I disable clicking on a panel while showing dialog?
I want to disable clicking on the background panel or frame while showing a dialogue. 我想在显示对话框时禁用单击背景面板或框架。 And I want the dialogue to appear on top of this panel or frame constantly until it is closed.
我希望对话框不断显示在此面板或框架的顶部,直到它关闭。
How can I do this? 我怎样才能做到这一点?
Make Dialog / JDialog modal by calling dialog.setModal(true);
通过调用
dialog.setModal(true);
Dialog / JDialog模式dialog.setModal(true);
. 。 This will solve both issues of clicking background panel and remaining on top of panel.
这将解决单击背景面板和保留在面板顶部的问题。
It seems like this method is obsolete so better you should use dialog.setModalityType(Dialog.ModalityType type)
看起来这个方法已经过时了,所以你应该使用
dialog.setModalityType(Dialog.ModalityType type)
您可以使用JOptionPane
作为消息对话框。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.