w.getToolkit().getSystemEventQueue().postEvent(new WindowEvent(w, WindowEvent.WINDOW_CLOSING));
obtained (with thanks) from: http://forums.java.net/jive/thread.jspa?threadID=35565
This will fire the
WindowClosing
event, so you can execute any action you may have bound to that event.