Example usage for java.awt Frame MAXIMIZED_HORIZ

List of usage examples for java.awt Frame MAXIMIZED_HORIZ

Introduction

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

Prototype

int MAXIMIZED_HORIZ

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

Click Source Link

Document

This state bit indicates that frame is maximized in the horizontal direction.

Usage

From source file:com.tag.FramePreferences.java

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

        @Override/* w  w  w. j av a  2s. 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:WindowEventDemo.java

public void checkWM() {
    Toolkit tk = frame.getToolkit();
    if (!(tk.isFrameStateSupported(Frame.ICONIFIED))) {
        displayMessage("Your window manager doesn't support ICONIFIED.");
    }/*from ww  w  .j  a va2s. c  om*/
    if (!(tk.isFrameStateSupported(Frame.MAXIMIZED_VERT))) {
        displayMessage("Your window manager doesn't support MAXIMIZED_VERT.");
    }
    if (!(tk.isFrameStateSupported(Frame.MAXIMIZED_HORIZ))) {
        displayMessage("Your window manager doesn't support MAXIMIZED_HORIZ.");
    }
    if (!(tk.isFrameStateSupported(Frame.MAXIMIZED_BOTH))) {
        displayMessage("Your window manager doesn't support MAXIMIZED_BOTH.");
    } else {
        displayMessage("Your window manager supports MAXIMIZED_BOTH.");
    }
}

From source file:WindowEventDemo.java

public void checkWM() {
    Toolkit tk = frame.getToolkit();
    if (!(tk.isFrameStateSupported(Frame.ICONIFIED))) {
        displayMessage("Your window manager doesn't support ICONIFIED.");
    } else//from w  w w. ja  v  a 2  s .  com
        displayMessage("Your window manager supports ICONIFIED.");
    if (!(tk.isFrameStateSupported(Frame.MAXIMIZED_VERT))) {
        displayMessage("Your window manager doesn't support MAXIMIZED_VERT.");
    } else
        displayMessage("Your window manager supports MAXIMIZED_VERT.");
    if (!(tk.isFrameStateSupported(Frame.MAXIMIZED_HORIZ))) {
        displayMessage("Your window manager doesn't support MAXIMIZED_HORIZ.");
    } else
        displayMessage("Your window manager supports MAXIMIZED_HORIZ.");
    if (!(tk.isFrameStateSupported(Frame.MAXIMIZED_BOTH))) {
        displayMessage("Your window manager doesn't support MAXIMIZED_BOTH.");
    } else {
        displayMessage("Your window manager supports MAXIMIZED_BOTH.");
    }
}

From source file:WindowEventDemo.java

String convertStateToString(int state) {
    if (state == Frame.NORMAL) {
        return "NORMAL";
    }//  ww  w  .j  av  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:events.WindowEventDemo.java

private String convertStateToString(int state) {
    if (state == Frame.NORMAL) {
        return "NORMAL";
    }/*w ww .j  a  v a 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:WindowEventDemo.java

private String convertStateToString(int state) {
    if (state == Frame.NORMAL) {
        return "NORMAL";
    }/*from  w  w  w  . j a v  a  2s.  com*/
    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:gmgen.GMGenSystem.java

private void setCloseSettings() {
    SettingsHandler.setGMGenOption(SETTING_WINDOW_X, this.getX());
    SettingsHandler.setGMGenOption(WINDOW_Y, this.getY());
    SettingsHandler.setGMGenOption(SETTING_WINDOW_WIDTH, this.getSize().width);
    SettingsHandler.setGMGenOption(SETTING_WINDOW_HEIGHT, this.getSize().height);

    // Maximized state of the window
    if ((getExtendedState() & Frame.MAXIMIZED_BOTH) != 0) {
        SettingsHandler.setGMGenOption(SETTING_WINDOW_STATE, Frame.MAXIMIZED_BOTH);
    } else if ((getExtendedState() & Frame.MAXIMIZED_HORIZ) != 0) {
        SettingsHandler.setGMGenOption(SETTING_WINDOW_STATE, Frame.MAXIMIZED_HORIZ);
    } else if ((getExtendedState() & Frame.MAXIMIZED_VERT) != 0) {
        SettingsHandler.setGMGenOption(SETTING_WINDOW_STATE, Frame.MAXIMIZED_VERT);
    } else {//from  ww  w . j  a v  a2s  .  c o  m
        SettingsHandler.setGMGenOption(SETTING_WINDOW_STATE, Frame.NORMAL);
    }
}

From source file:net.pms.newgui.components.WindowProperties.java

private boolean updateWindowBounds(@Nullable Window eventWindow) {
    if (eventWindow != window) {
        return false;
    }//ww  w .  ja  va2 s  .co m
    int state = eventWindow instanceof Frame ? ((Frame) eventWindow).getExtendedState() : 0;
    Rectangle bounds;
    if (state == 0) {
        bounds = eventWindow.getBounds();
    } else if ((state & Frame.MAXIMIZED_BOTH) != Frame.MAXIMIZED_BOTH) {
        bounds = eventWindow.getBounds();
        // Don't store maximized dimensions
        if ((state & Frame.MAXIMIZED_HORIZ) != 0) {
            bounds.x = windowBounds.x;
            bounds.width = windowBounds.width;
        } else if ((state & Frame.MAXIMIZED_VERT) != 0) {
            bounds.y = windowBounds.y;
            bounds.height = windowBounds.height;
        }
    } else {
        bounds = windowBounds;
    }
    boolean changed = !bounds.equals(windowBounds);
    if (changed) {
        windowBounds = bounds;
    }
    if (windowState != (byte) state) {
        windowState = (byte) state;
        changed = true;
    }
    return changed;
}

From source file:edu.ku.brc.ui.UIHelper.java

/**
 * @param frame to be positioned/*from  w  ww. java  2 s  .  c  o m*/
 * 
 * positions frame on screen relative to position of TOPFRAME.
 * Sets frame.alwaysOnTop to true if TOPFRAME is maximized.
 */
public static void positionFrameRelativeToTopFrame(final JFrame frame) {
    // not sure of safest surest way to get main window???
    JFrame topFrame = (JFrame) UIRegistry.getTopWindow();

    // for now this just sets the top of frame to the top of topFrame
    // if there is room on the left side of topFrame, frame is set so it's right edge is next to topFrame's left edge.
    // otherwise, if frame will fit, frame's left edge is aligned with topFrame's right edge.
    // If it won't fit then frame's right edge is aligned with right of edge of screen.
    if (topFrame != null) {
        int x = 0;
        int y = topFrame.getY();
        Rectangle screenRect = topFrame.getGraphicsConfiguration().getBounds();
        if (topFrame.getX() >= frame.getWidth()) {
            x = topFrame.getX() - frame.getWidth();
        } else if (screenRect.width - topFrame.getX() - topFrame.getWidth() >= frame.getWidth()) {
            x = topFrame.getWidth();
        } else {
            x = screenRect.width - frame.getWidth();
        }
        frame.setBounds(x, y, frame.getWidth(), frame.getHeight());

        frame.setAlwaysOnTop(topFrame.getExtendedState() == Frame.MAXIMIZED_BOTH
                || topFrame.getExtendedState() == Frame.MAXIMIZED_VERT
                || topFrame.getExtendedState() == Frame.MAXIMIZED_HORIZ);
    }
}