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.
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.
精彩评论