开发者

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 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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜