Example usage for java.awt.event WindowEvent WINDOW_ACTIVATED

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

Introduction

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

Prototype

int WINDOW_ACTIVATED

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

Click Source Link

Document

The window-activated event type.

Usage

From source file:Main.java

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

From source file:Main.java

protected void processWindowEvent(WindowEvent e) {
    System.out.println(e.getOldState() == WindowEvent.WINDOW_ACTIVATED);
    super.processWindowEvent(e); // Pass on the event
}

From source file:Main.java

protected void processWindowEvent(WindowEvent e) {
    System.out.println(e.getNewState() == WindowEvent.WINDOW_ACTIVATED);
    super.processWindowEvent(e); // Pass on the event
}

From source file:Main.java

protected void processWindowEvent(WindowEvent e) {
    WindowEvent newEvent = new WindowEvent(this, WindowEvent.WINDOW_ACTIVATED);

    super.processWindowEvent(e); // Pass on the event
}

From source file:Main.java

protected void processWindowEvent(WindowEvent e) {
    WindowEvent newEvent = new WindowEvent(this, WindowEvent.WINDOW_FIRST, WindowEvent.WINDOW_CLOSED,
            WindowEvent.WINDOW_ACTIVATED);

    super.processWindowEvent(e); // Pass on the event
}

From source file:Main.java

protected void processWindowEvent(WindowEvent e) {
    WindowEvent newEvent = new WindowEvent(this, WindowEvent.WINDOW_FIRST, this, WindowEvent.WINDOW_CLOSED,
            WindowEvent.WINDOW_ACTIVATED);

    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 w w.  j av  a 2 s.c  o m
    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);
    }
}

From source file:org.eclipse.jubula.rc.swing.listener.ComponentHandler.java

/**
 * {@inheritDoc}/*  w w  w.  jav a 2  s.co m*/
 */
public void eventDispatched(AWTEvent event) {

    final ClassLoader originalCL = Thread.currentThread().getContextClassLoader();
    Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
    try {
        if (log.isDebugEnabled()) {
            log.debug(event.paramString());
        }
        final int id = event.getID();
        ComponentEvent componentEvent;
        switch (id) {
        case WindowEvent.WINDOW_ACTIVATED:
        case WindowEvent.WINDOW_OPENED:
            // add recursivly all components to AUTHierarchy 
            // and create names for unnamed components
            Window window = ((WindowEvent) event).getWindow();
            autHierarchy.add(window);
            break;
        case ContainerEvent.COMPONENT_ADDED:
            checkContainerListener((ContainerEvent) event);
            break;
        case ComponentEvent.COMPONENT_HIDDEN:
            componentEvent = (ComponentEvent) event;
            if (!hasListener(componentEvent.getComponent(), ComponentListener.class)) {
                autHierarchy.componentHidden(componentEvent);
            }
            break;
        case ComponentEvent.COMPONENT_SHOWN:
            componentEvent = (ComponentEvent) event;
            if (!hasListener(componentEvent.getComponent(), ComponentListener.class)) {
                autHierarchy.componentShown(componentEvent);
            }
            break;
        default:
            // do nothing
        }
        if (AUTServer.getInstance().getMode() == ChangeAUTModeMessage.OBJECT_MAPPING) {

            AUTServer.getInstance().updateHighLighter();
        }
    } catch (Throwable t) {
        log.error("exception during ComponentHandler", t); //$NON-NLS-1$
    } finally {
        Thread.currentThread().setContextClassLoader(originalCL);
    }
}

From source file:studio.ui.Studio.java

@Override
protected void processWindowEvent(WindowEvent event) {
    switch (event.getID()) {
    case WindowEvent.WINDOW_CLOSING:
        if (tabEditors != null && tabEditors.getTabCount() > 0) {
            int current = tabEditors.getSelectedIndex();
            boolean close = true;
            for (int count = 0; close & count < tabEditors.getTabCount(); count++) {
                Editor editor = tabEditors.getEditor(count);
                if (editor != null) {
                    if (editor.getFile() != null) {
                        editor.getFile().setActive(count == current);
                    }/*from w  w w. java 2s  .c  o m*/
                    if (editor.isModified() && !editor.isEmpty()) {
                        tabEditors.setSelectedIndex(count);
                        close &= tabEditors.closeEditor(editor);
                    }
                }
            }
            if (!close) {
                tabEditors.setSelectedIndex(current);
                tabEditors.getEditor(current).requestFocus();
                return;
            } else {
                for (int count = 0; count < tabEditors.getTabCount(); count++) {
                    if (tabEditors.getEditor(count) != null) {
                        tabEditors.getEditor(count).setModified(false);
                    }
                }
            }
        }

        java.util.List<EditorFile> files = tabEditors.saveFiles();
        if (files == null) {
            return;
        }
        try {
            studioConfig.setLastFiles(files);
        } catch (ConfigException ex) {
            ex.printStackTrace();
        }
        super.processWindowEvent(event);
        System.exit(0);
        break;
    case WindowEvent.WINDOW_ACTIVATED:
        if (tabEditors != null && tabEditors.getTabCount() > 0 && tabEditors.getEditor() != null) {
            tabEditors.getEditor().requestFocusInWindow();
        }
        break;
    }
    super.processWindowEvent(event);
}