Example usage for java.awt Frame NORMAL

List of usage examples for java.awt Frame NORMAL

Introduction

In this page you can find the example usage for java.awt Frame NORMAL.

Prototype

int NORMAL

To view the source code for java.awt Frame NORMAL.

Click Source Link

Document

Frame is in the "normal" state.

Usage

From source file:Main.java

public static void main(String[] args) throws InterruptedException {
    JFrame frame = new JFrame();
    frame.add(new JLabel("Minimize demo"));
    frame.pack();/*from  ww  w.  j av  a2  s.  c  o  m*/

    // Show the frame
    frame.setVisible(true);

    // Sleep for 5 seconds, then minimize
    Thread.sleep(5000);
    frame.setState(Frame.ICONIFIED);

    // Sleep for 5 seconds, then restore
    Thread.sleep(5000);
    frame.setState(Frame.NORMAL);

    // Sleep for 5 seconds, then kill window
    Thread.sleep(5000);
    frame.setVisible(false);
    frame.dispose();

    // Terminate test
    System.exit(0);
}

From source file:Main.java

public static void main(String args[]) throws Exception {
    // Create a test frame
    Frame frame = new Frame("Hello");
    frame.add(new Label("Minimize demo"));
    frame.pack();//from   ww  w . j a  v a  2  s  .c om

    // Show the frame
    frame.setVisible(true);

    // Sleep for 5 seconds, then minimize
    Thread.sleep(5000);
    frame.setState(Frame.ICONIFIED);
    frame.setVisible(false);
    // Sleep for 5 seconds, then restore
    Thread.sleep(5000);
    frame.setState(Frame.NORMAL);
    frame.setVisible(true);

    // Sleep for 5 seconds, then kill window
    Thread.sleep(5000);
    frame.setVisible(false);
    frame.dispose();

    // Terminate test
    System.exit(0);
}

From source file:Main.java

public void componentResized(ComponentEvent e) {
    System.out.println("componentResized");

    if (getState() == Frame.ICONIFIED) {
        System.out.println("RESIZED TO ICONIFIED");
    } else if (getState() == Frame.NORMAL) {
        System.out.println("RESIZED TO NORMAL");
    } else {//from w w w  .j  a  v a2s.com
        System.out.println("RESIZED TO MAXIMIZED");
    }
}

From source file:com.tag.FramePreferences.java

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

        @Override//from w ww. ja v a 2  s. c o  m
        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:iqq.app.ui.manager.MainManager.java

public void show() {
    if (mainFrame == null) {
        mainFrame = new MainFrame();
        mainFrame.setVisible(true);/*from   ww w. j  av  a  2  s .co m*/
        mainFrame.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
        enableTray();
    }
    if (!mainFrame.isVisible()) {
        mainFrame.setVisible(true);// ??
        // ??(??)
        mainFrame.setExtendedState(Frame.NORMAL);
    }
}

From source file:fr.jmmc.jmcs.logging.LogbackGui.java

/**
 * Display the logger editor//from w ww.  j  a va 2  s .co m
 * @param parent parent frame used to center this window (null means center on screen)
 * @param name name of the editor frame
 * @param loggerPath logger path
 */
public static void showWindow(final JFrame parent, final String name, final String loggerPath) {
    if (_guiFrameSingleton != null) {
        _guiFrameSingleton.toFront();

        // ensure window is visible (not iconified):
        if (_guiFrameSingleton.getState() == Frame.ICONIFIED) {
            _guiFrameSingleton.setState(Frame.NORMAL);
        }

        // force the frame to be visible and bring it to front
        _guiFrameSingleton.setVisible(true);
        _guiFrameSingleton.toFront();
    } else {
        final String frameName = (name != null) ? name : "Log Console";

        // Create Gui:
        _guiSingleton = new LogbackGui();

        // 1. Create the frame
        _guiFrameSingleton = new JFrame(frameName) {
            /** default serial UID for Serializable interface */
            private static final long serialVersionUID = 1L;

            /**
             * Free any resource or reference to this instance :
             * stop the Swing timer if started
             */
            @Override
            public void dispose() {
                // free LogbackGui resources:
                _guiSingleton.onDispose();

                // free singletons:
                _guiSingleton = null;
                _guiFrameSingleton = null;

                // dispose Frame :
                super.dispose();
            }
        };

        final Dimension dim = new Dimension(700, 500);
        _guiFrameSingleton.setMinimumSize(dim);
        _guiFrameSingleton.addComponentListener(new ComponentResizeAdapter(dim));

        // 2. Optional: What happens when the frame closes ?
        _guiFrameSingleton.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

        // 3. Create components and put them in the frame
        _guiFrameSingleton.add(_guiSingleton);

        // 4. Size the frame.
        _guiFrameSingleton.pack();

        // Center it :
        WindowUtils.centerOnMainScreen(_guiFrameSingleton);
        WindowUtils.setClosingKeyboardShortcuts(_guiFrameSingleton);

        // 5. Show it and waits until frame is not visible or disposed :
        _guiFrameSingleton.setVisible(true);
    }

    // Select the log tab:
    _guiSingleton.selectLogTab(loggerPath);
}

From source file:WindowEventDemo.java

String convertStateToString(int state) {
    if (state == Frame.NORMAL) {
        return "NORMAL";
    }/*from  ww  w.  j  a  v  a2  s.c  o m*/
    if ((state & Frame.ICONIFIED) != 0) {
        return "ICONIFIED";
    }
    //MAXIMIZED_BOTH is a concatenation of two bits, so
    //we need to test for an exact match.
    if ((state & Frame.MAXIMIZED_BOTH) == Frame.MAXIMIZED_BOTH) {
        return "MAXIMIZED_BOTH";
    }
    if ((state & Frame.MAXIMIZED_VERT) != 0) {
        return "MAXIMIZED_VERT";
    }
    if ((state & Frame.MAXIMIZED_HORIZ) != 0) {
        return "MAXIMIZED_HORIZ";
    }
    return "UNKNOWN";
}

From source file:net.chaosserver.timelord.swingui.engine.BringToFrontThread.java

/**
 * Trigger an annoy by un-minimizing the window and bringing it to the
 * front./*from   www.  j  a  va  2  s .  c  o m*/
 */
protected void annoy() {
    lastAnnoy = System.currentTimeMillis();
    getFrame().setExtendedState(Frame.NORMAL);
    getFrame().toFront();
    getTimelord().showTodayTab();

    // This bounces the Dock in Panther/Tiger
    try {
        Class<?> nsApplicationClass = Class.forName("com.apple.cocoa.application.NSApplication");

        Method sharedAppMethod = nsApplicationClass.getDeclaredMethod("sharedApplication", new Class[] {});

        Object nsApplicationObject = sharedAppMethod.invoke(null, new Object[] {});

        Field userAttentionRequestCriticalField = nsApplicationClass
                .getDeclaredField("UserAttentionRequestCritical");

        Method requestUserAttentionMethod = nsApplicationClass.getDeclaredMethod("requestUserAttention",
                new Class[] { userAttentionRequestCriticalField.getType() });

        requestUserAttentionMethod.invoke(nsApplicationObject,
                new Object[] { userAttentionRequestCriticalField.get(null) });
    } catch (Exception e) {
        if (log.isDebugEnabled()) {
            log.debug("Issue bouncing dock", e);
        }
    }

    if (log.isTraceEnabled()) {
        log.trace("Bringing Window to Front");
    }
}

From source file:events.WindowEventDemo.java

private String convertStateToString(int state) {
    if (state == Frame.NORMAL) {
        return "NORMAL";
    }//from   w w w. j ava 2  s . c  o  m
    String strState = " ";
    if ((state & Frame.ICONIFIED) != 0) {
        strState += "ICONIFIED";
    }
    //MAXIMIZED_BOTH is a concatenation of two bits, so
    //we need to test for an exact match.
    if ((state & Frame.MAXIMIZED_BOTH) == Frame.MAXIMIZED_BOTH) {
        strState += "MAXIMIZED_BOTH";
    } else {
        if ((state & Frame.MAXIMIZED_VERT) != 0) {
            strState += "MAXIMIZED_VERT";
        }
        if ((state & Frame.MAXIMIZED_HORIZ) != 0) {
            strState += "MAXIMIZED_HORIZ";
        }
    }
    if (" ".equals(strState)) {
        strState = "UNKNOWN";
    }
    return strState.trim();
}

From source file:com.tag.FramePreferences.java

public int getPreferredExtendedState() {
    Preferences prefs = getPreferences();
    return prefs.getInt(KEY_EXTENDED_STATE, Frame.NORMAL);
}