简体   繁体   中英

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); . 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)

您可以使用JOptionPane作为消息对话框。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM