Code example for WindowEvent

0
            } 
        }); 
    } 
 
    public static void closeWindow(Window w) {
        w.getToolkit().getSystemEventQueue().postEvent(new WindowEvent(w, WindowEvent.WINDOW_CLOSING));
    } 
 
    public static Frame getFrame(Component c) {
        Component ret = c;
        while (ret != null && !(ret instanceof Frame)) {
            ret = ret.getParent();
        } 
        return (Frame) ret;
    } 
 
    public static JFrame getJFrame(Component c) {
        Component ret = c;
        while (ret != null && !(ret instanceof JFrame)) {
            ret = ret.getParent();