开发者

Java: How can I disable clicking on a panel while showing dialog?

开发者 https://www.devze.com 2023-04-09 00:44 出处:网络
I want to disable clicking on the background panel or frame while showing a dialogue. And I want the dialogue t开发者_如何学Co appear on top of this panel or frame constantly until it is closed.

I want to disable clicking on the background panel or frame while showing a dialogue. And I want the dialogue t开发者_如何学Co appear on top of this panel or frame constantly until it is closed.

Java: How can I disable clicking on a panel while showing dialog?

How can I do this?


Make Dialog/JDialog modal by calling 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)


You can use JOptionPane for the message dialog.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号