Example usage for java.awt.event WindowEvent WINDOW_DEACTIVATED

List of usage examples for java.awt.event WindowEvent WINDOW_DEACTIVATED

Introduction

In this page you can find the example usage for java.awt.event WindowEvent WINDOW_DEACTIVATED.

Prototype

int WINDOW_DEACTIVATED

To view the source code for java.awt.event WindowEvent WINDOW_DEACTIVATED.

Click Source Link

Document

The window-deactivated event type.

Usage

From source file:Main.java

protected void processWindowEvent(WindowEvent e) {
    if (e.getID() == WindowEvent.WINDOW_DEACTIVATED) {
        System.out.println(WindowEvent.WINDOW_DEACTIVATED);
        dispose();/*from  w w  w  .  j a  v a 2s .  c o  m*/
        System.exit(0);
    }
    super.processWindowEvent(e); // Pass on the event
}

From source file:EventTestPane.java

/** Display Window events. Note the special handling of WINDOW_CLOSING */
public void processWindowEvent(WindowEvent e) {
    switch (e.getID()) {
    case WindowEvent.WINDOW_OPENED:
        showLine("WINDOW_OPENED");
        break;//from   w ww .j a v a  2s  . c  om
    case WindowEvent.WINDOW_CLOSED:
        showLine("WINDOW_CLOSED");
        break;
    case WindowEvent.WINDOW_CLOSING:
        showLine("WINDOW_CLOSING");
        break;
    case WindowEvent.WINDOW_ICONIFIED:
        showLine("WINDOW_ICONIFIED");
        break;
    case WindowEvent.WINDOW_DEICONIFIED:
        showLine("WINDOW_DEICONIFIED");
        break;
    case WindowEvent.WINDOW_ACTIVATED:
        showLine("WINDOW_ACTIVATED");
        break;
    case WindowEvent.WINDOW_DEACTIVATED:
        showLine("WINDOW_DEACTIVATED");
        break;
    }

    // If the user requested a window close, quit the program.
    // But first display a message, force it to be visible, and make
    // sure the user has time to read it.
    if (e.getID() == WindowEvent.WINDOW_CLOSING) {
        showLine("WINDOW_CLOSING event received.");
        showLine("Application will exit in 5 seconds");
        // Force the updates to appear now.
        update(this.getGraphics());
        // Wait five seconds
        try {
            Thread.sleep(5000);
        } catch (InterruptedException ie) {
            ;
        }
        // Exit now
        System.exit(0);
    }
}