This is my main method and it contains a shutdownhook:
public static void main(String args[]) {
Runtime.getRuntime().addShutdownHook(new Thread() {
@Override
public void run() {
JOptionPane.showMessageDialog(null, "Shutdown hook");
}
});
/* Create and display the form */
java.awt.EventQueue.invokeLater(
new Runnable() {
@Override
public void run() {
Thread.setDefaultUncaughtExceptionHandler(new MyUncaughtExceptionHandler());
MyFrame frame = new MyFrame();
frame.setVisible(true);
}
});
}
The problem is the JOptionPane
doesn't show up at all. Instead, the frame closes but the app itself still runs.
PS. I can't use the WindowClosing
event because it doesn't fire on the Cmd+Q command on Mac OS X.