I'm currently programming a little Java game and I use the JOptionPane
class to alert the user if an IOException
is thrown. I'd like to know how to prevent the option pane from being "closed" by clicking anywhere else, e.g. on the desktop, because it actually doesn't end the Java process.
Asked
Active
Viewed 102 times
0

Andrew Thompson
- 168,117
- 40
- 217
- 433

Algorythmis
- 642
- 1
- 7
- 19
-
Huh? Clicking elsewhere does not close a dialog. – SLaks May 08 '16 at 15:12
-
Clicking anywhere else brings that window to the front and gives it focus. The JOptionPane is still present, just hidden behind the front window. This is operating system behavior, and there's nothing you can do about it. – Gilbert Le Blanc May 08 '16 at 15:17
-
@SLaks https://youtu.be/SM4TGU3NcHo – Algorythmis May 08 '16 at 15:20
-
Uh, thanks @GilbertLeBlanc but how do I find the JOptionPane to close it then? – Algorythmis May 08 '16 at 15:21
-
To find the JOptionPane, close every other open window. – Gilbert Le Blanc May 08 '16 at 15:22
-
or just minimize them, or look in Alt+Tab. – SLaks May 08 '16 at 15:22
-
Even when I close everything, the JOptionPane isn't visible anywhere. But still thanks. – Algorythmis May 08 '16 at 15:26
-
Does the option pane have a 'parent/owner'? Never mind.. For better help sooner, post a [MCVE] or [Short, Self Contained, Correct Example](http://www.sscce.org/). That will answer my question as well. – Andrew Thompson May 08 '16 at 15:46