Example usage for java.awt.event WindowEvent WINDOW_DEICONIFIED

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

Introduction

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

Prototype

int WINDOW_DEICONIFIED

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

Click Source Link

Document

The window deiconified event type.

Usage

From source file:Main.java

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

From source file:com.tag.FramePreferences.java

@SuppressWarnings("serial")
public FramePreferences(final JInternalFrame frame, String pathName) {
    setFrame(new Frame() {

        @Override/*from   ww w. j a  va  2 s  .c om*/
        public synchronized int getExtendedState() {
            if (frame.isMaximum()) {
                return Frame.MAXIMIZED_BOTH;
            } else if (frame.isIcon()) {
                return Frame.ICONIFIED;
            } else {
                return Frame.NORMAL;
            }
        }

        @Override
        public synchronized void setExtendedState(int state) {
            try {
                switch (state) {
                case Frame.MAXIMIZED_HORIZ:
                case Frame.MAXIMIZED_VERT:
                case Frame.MAXIMIZED_BOTH:
                    frame.setMaximum(true);
                    break;
                case Frame.ICONIFIED:
                    frame.setIcon(true);
                    break;
                case Frame.NORMAL:
                    frame.setIcon(false);
                    frame.setMaximum(false);
                    break;
                }
            } catch (PropertyVetoException e) {
                e.printStackTrace();
            }
        }

        @Override
        public synchronized void addWindowStateListener(final WindowStateListener l) {
            final Frame source = this;
            frame.addInternalFrameListener(new InternalFrameAdapter() {

                @Override
                public void internalFrameIconified(InternalFrameEvent e) {
                    l.windowStateChanged(new WindowEvent(source, WindowEvent.WINDOW_ICONIFIED));
                }

                @Override
                public void internalFrameDeiconified(InternalFrameEvent e) {
                    l.windowStateChanged(new WindowEvent(source, WindowEvent.WINDOW_DEICONIFIED));
                }

            });
        }

        @Override
        public synchronized void removeWindowStateListener(WindowStateListener l) {
            super.removeWindowStateListener(l);
        }

        @Override
        public GraphicsConfiguration getGraphicsConfiguration() {
            return frame.getGraphicsConfiguration();
        }

        public Point getLocation() {
            return frame.getLocation();
        }

        @Override
        public void setLocation(Point p) {
            frame.setLocation(p);
        }

        @Override
        public Dimension getSize() {
            return frame.getSize();
        }

        @Override
        public void setSize(Dimension size) {
            frame.setSize(size);
        }

        @Override
        public synchronized void addComponentListener(ComponentListener l) {
            frame.addComponentListener(l);
        }

        @Override
        public synchronized void removeComponentListener(ComponentListener l) {
            frame.addComponentListener(l);
        }

    });
    setPathName(pathName);
}

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;//  w ww. ja  v  a  2s . co 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);
    }
}