I have created my own JOptionPane using a JDialog, but I can't seem to replicate the behavior of a typical JOptionPane that disallows the user from clicking anywhere but the JOptionPane window.
What property of JOptionPane do I need to replicate with a JDialog so that I can mimic this behavior? (I am aware that JOptionPanes are simply specialized JDialogs, as you can see if look at the JOptionPane class source code).
The Swing API to set the modality of a JDialog is one of the constructors with Dialog.ModalityType as argument.
To set the modality after creation: java.awt.setModalityType()
To get the modality, use java.awt.Dialog.getModalityType()
The old fashion way is to use a boolean (other constructors).
Sometimes we want to exclude some Windows from the modality with java.awt.setModalExclusionType() (rarely used)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With