質問

I have my observer pattern working fine for my JDialog, update() is called when my observer gets changed, as i would expect. I am also keeping a track of the observer count in my observable, (Which is 1 with the JDialog open).

I am now to trying to set the Modality of my JDialog in order to make my main window unusable while the dialog is open. However, if i use

dialog.setModalityType(ModalityType.APPLICATION_MODAL);

I can no longer see my JDialog in my observable object, and the update() does not get called. It appears as if its not setting the observer correctly.

Can anyone shed any light on this? What can i do to get around this?

役に立ちましたか?

解決

Often this problem is caused by not taking order of program flow into consideration.

Make sure that you set up your observer fully, including adding all listeners and starting any and all processes before setting the dialog visible. If you do any of this after showing the dialog, it will be blocked until the dialog returns.

For more specific help, consider creating and posting a minimal example program.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top