Reputation: 25018
The defaultCloseOperation()
in my JFrame is set to DO_NOTHING_ON_CLOSE
. The IDE shows that the program is still running and there is no way to get the JFrame
back.
I want to know, how do I get the JFrame
to be visible again if a certain key combination is pressed like SHIFT+V
? Like in some parental control and surveillance softwares
I know KeyListener
can not be used cause it needs something focussable to which input can be sent... so what is the way around ??
Can it reappear when some keys are pressed ?
Upvotes: 1
Views: 128
Reputation: 109823
not directly and possible with Java, Swing GUI doesn't reacting to any Key or Mouse Events if isn't visible on the screen and hasn't Focus owner
you can use SystemTray as standard workaround, there you can from JMenuItems Action to display your container again
EDIT
Upvotes: 1
Reputation: 73
First of you make a windows adapter so that you can use the windowClosing method inside it. This method overrides the default EXIT_ON_CLOSE or in you case DO_NOTHING_ON_CLOSE and write what you want to happen when the program tries to exit on the red X. Hope it helps
Upvotes: 1