Example usage for java.awt Window dispatchEvent

List of usage examples for java.awt Window dispatchEvent

Introduction

In this page you can find the example usage for java.awt Window dispatchEvent.

Prototype

public final void dispatchEvent(AWTEvent e) 

Source Link

Document

Dispatches an event to this component or one of its sub components.

Usage

From source file:Main.java

public static void closeWindow(Window window) {
    window.dispatchEvent(new WindowEvent(window, WindowEvent.WINDOW_CLOSING));
}

From source file:com.limegroup.gnutella.gui.GUIUtils.java

/**
 * Returns (possibly constructing) the ESC action.
 *//*from ww  w.ja  va2 s  .c  om*/
public static Action getDisposeAction() {
    if (ACTION_DISPOSE == null) {
        ACTION_DISPOSE = new AbstractAction() {

            /**
             * 
             */
            private static final long serialVersionUID = 3219036624812939826L;

            public void actionPerformed(ActionEvent ae) {
                Window parent;
                if (ae.getSource() instanceof Window)
                    parent = (Window) ae.getSource();
                else
                    parent = SwingUtilities.getWindowAncestor((Component) ae.getSource());

                if (parent != null)
                    parent.dispatchEvent(new WindowEvent(parent, WindowEvent.WINDOW_CLOSING));
            }
        };
    }
    return ACTION_DISPOSE;
}