Example usage for java.awt.event WindowEvent getSource

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

Introduction

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

Prototype

public Object getSource() 

Source Link

Document

The object on which the Event initially occurred.

Usage

From source file:uk.co.modularaudio.componentdesigner.ComponentDesigner.java

public void registerCloseAction() throws DatastoreException {
    mainFrame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
    mainFrame.addWindowListener(new WindowListener() {
        @Override/*from w w  w. jav  a 2  s  . com*/
        public void windowClosed(final WindowEvent e) {
            log.debug("Window closed event received");
        }

        @Override
        public void windowOpened(final WindowEvent e) {
            try {
                log.debug("Window opening event received - setting thread to lowest priority.");
                ThreadUtils.setCurrentThreadPriority(MAThreadPriority.APPLICATION);
                if (log.isDebugEnabled()) {
                    log.debug("Now set to " + MAThreadPriority.APPLICATION);
                }
            } catch (final Exception ie) {
                final String msg = "Exception caught setting gui thread priority: " + ie.toString();
                log.error(msg, ie);
            }
        }

        @Override
        public void windowClosing(final WindowEvent e) {
            log.debug("Window closing event received.");
            final Action exitAction = mainFrameActions.getExitAction();
            final ActionEvent exitActionEvent = new ActionEvent(e.getSource(), e.getID(), "");
            exitAction.actionPerformed(exitActionEvent);
        }

        @Override
        public void windowIconified(final WindowEvent e) {
        }

        @Override
        public void windowDeiconified(final WindowEvent e) {
        }

        @Override
        public void windowActivated(final WindowEvent e) {
        }

        @Override
        public void windowDeactivated(final WindowEvent e) {
        }
    });
}