Or more exact:
I need to know on a window close event, if any other window is still visible.
If not, System.exit(0) would be called.
1) I need to know on a window close event
there are WindowConstants and WindowEvent
2) if any other window is still visible.
you can get number of Top-Level Containers by using Window[] wins = Window.getWindows(); for testing their visibility or by adding WindowStateListener
some important notice here
Try
if(Frame.getFrames().length == 0) {
// work here.
}
(Frame is java.awt.Frame, that is the parent of JFrame, so you will capture them, too).
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