Example usage for javafx.stage Stage isMaximized

List of usage examples for javafx.stage Stage isMaximized

Introduction

In this page you can find the example usage for javafx.stage Stage isMaximized.

Prototype

public final boolean isMaximized() 

Source Link

Usage

From source file:ambroafb.general.StagesContainer.java

public static void saveSizeFor(Stage stage) {
    try {//from w  w  w .j a  v a 2  s  .  c o  m
        String path = getPathForStage(stage);
        JSONObject jsonForStageSize = new JSONObject();
        jsonForStageSize.put("width", stage.getWidth());
        jsonForStageSize.put("height", stage.getHeight());
        jsonForStageSize.put("isMaximized", stage.isMaximized());
        GeneralConfig.prefs.put("stage_size_" + path, jsonForStageSize.toString());
    } catch (JSONException ex) {
        Logger.getLogger(Utils.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:org.eclipse.jubula.rc.javafx.driver.RobotJavaFXImpl.java

/**
 * Refreshes the complete layout and returns the bounds of the given
 * Component.//from  ww w. jav a  2 s  . co  m
 *
 * @param comp
 *            the Component
 * @param clickOp
 *            not used
 * @return Rectangle with the Bounds
 */
private Rectangle getComponentBounds(final Object comp, ClickOptions clickOp) {

    ComponentHandler.syncStageResize();
    Rectangle bounds = null;
    if (comp instanceof Stage) {
        Stage s = (Stage) comp;
        bounds = new Rectangle(new Point(Rounding.round(s.getX()), Rounding.round(s.getY())));

        // This is not multi display compatible
        Screen screen = Screen.getPrimary();
        final Rectangle2D screenBounds = screen.getBounds();
        int displayWidth = Rounding.round(screenBounds.getWidth());
        int displayHeight = Rounding.round(screenBounds.getHeight());
        if (s.isFullScreen()) {
            bounds.width = Rounding.round(displayWidth);
            bounds.height = Rounding.round(displayHeight);
        } else if (s.isMaximized()) {
            int x = Rounding.round(s.getX());
            int y = Rounding.round(s.getY());
            // trimming the bounds to the display if necessary
            bounds.width = Rounding.round(s.getWidth());
            bounds.height = Rounding.round(s.getHeight());
            if (x < 0 || y < 0) {
                bounds.x = 0;
                bounds.y = 0;
                if (bounds.width > displayWidth) {
                    bounds.width = displayWidth;
                }
                if (bounds.height > displayHeight) {
                    bounds.height = displayHeight;
                }
            }
        } else {
            bounds.width = Rounding.round(s.getWidth());
            bounds.height = Rounding.round(s.getHeight());
        }
    } else {
        final Node node = (Node) comp;
        if (clickOp.isScrollToVisible()) {
            ensureComponentVisible(node);
        }
        bounds = EventThreadQueuerJavaFXImpl.invokeAndWait("Robot get node bounds", new Callable<Rectangle>() { //$NON-NLS-1$

            @Override
            public Rectangle call() throws Exception {
                Rectangle bs = new Rectangle(getLocation(node, new Point(0, 0)));
                Bounds b = node.getBoundsInParent();
                bs.width = Rounding.round(b.getWidth());
                bs.height = Rounding.round(b.getHeight());
                return bs;
            }
        });

    }
    return bounds;
}