setModalityType() not yet supported
This is a follow up issue to the issue here: https://github.com/leaningtech/cheerpj-appletrunner/issues/16#issuecomment-455589518
I just noticed that modal dialogs are not fully modal. I can still interact with the menu bar of the applet. As a result I can open the same modal dialog multiple times. Here I open it the first time:
Now I can still interact with the menu of the applet, and can open the modal dialog a second time:

The second modal dialog opens on top of the present modal dialog:
Usually for modal dialogs, the menus are blocked. It is even so that Swing does a "beep", when I try to click into the menus.
BTW: I am using advanced Swing API to set the dialog to modal. The advanced Swing API allows different sub modes of modal. My code contains the following API call before making it visible:
setModalityType(Dialog.ModalityType.DOCUMENT_MODAL);
setVisible(true);
I use the advanced Swing API for some requirements for when the code runs not from within a single applet, but when I have multiple windows. Hold on, let me also test the traditional API.
Intersting I changed the code to the following:
setModal(true);
// setModalityType(Dialog.ModalityType.DOCUMENT_MODAL);
setVisible(true);
And now the menu is blocked. Oki Doki. So the advanced API is not yet working for applets. I can workaround my code accordingly.
Hi @jburse , thanks for your report!
How did you create the JDialog? If you didn't specify the parent, Dialog.ModalityType.DOCUMENT_MODAL is not enough to prevent clicking on the applet.
You should use something like :
setModalityType(Dialog.ModalityType.APPLICATION_MODAL);
(Which should be equivalent to your workaround of setModal(true))
Can you provide us a test case showing different behaviour between CheerpJ and native Java (leaving aside the window stacking issue tracked in https://github.com/leaningtech/cheerpj-appletrunner/issues/31 )?
If you don't specify a parent, it still has a parent. At least the JDK 1.8 source tells me:
super(owner == null?
SwingUtilities.getSharedOwnerFrame() : owner,
title, modal);
As soon as I have time, I can make more testing with different modalities (there are not many).
@jburse The simplest thing would be for you to revert the workaround (i.e. using setModal(true)) so that we can directly test our applet.