Example usage for javafx.stage Screen getVisualBounds

List of usage examples for javafx.stage Screen getVisualBounds

Introduction

In this page you can find the example usage for javafx.stage Screen getVisualBounds.

Prototype

public final Rectangle2D getVisualBounds() 

Source Link

Document

Gets the visual bounds of this Screen .

Usage

From source file:org.jevis.jeconfig.JEConfig.java

/**
 * maximized the given stage/*from   w  w w  .  j av  a 2s .co  m*/
 *
 * @param primaryStage
 */
public static void maximize(Stage primaryStage) {
    Screen screen = Screen.getPrimary();
    Rectangle2D bounds = screen.getVisualBounds();

    primaryStage.setX(bounds.getMinX());
    primaryStage.setY(bounds.getMinY());
    primaryStage.setWidth(bounds.getWidth());
    primaryStage.setHeight(bounds.getHeight());
}

From source file:com.fishbeans.app.FXMLComponentBase.java

public Parent getRootNode() {

    setupFxmlReloader();//from w ww .  j a va 2s  . c  o m

    Parent parent = fxmlLoader.getRoot();
    Screen screen = Screen.getPrimary();
    Rectangle2D bounds = screen.getVisualBounds();
    ViewController controller = (ViewController) fxmlLoader.getController();
    controller.set2DBounds(bounds);

    return parent;
}

From source file:wpdisplaytest.WPDisplayTest.java

private void moveToSecondaryIfExists(Stage stage) {
    Screen secondary;
    try {//  w  w  w. j  a v  a  2s. c  o m
        secondary = Screen.getScreens().stream().filter(E -> {
            return !E.equals(Screen.getPrimary());
        }).findFirst().get();
        Rectangle2D bounds = secondary.getVisualBounds();
        stage.setX(bounds.getMinX());
        stage.setY(bounds.getMinY());
        stage.centerOnScreen();
    } catch (NoSuchElementException ex) {
        //There is no secondary viewport, fail silently
    }

}

From source file:org.openbase.display.DisplayView.java

/**
 * {@inheritDoc}//from   ww  w  . ja v a2  s.  c o m
 *
 * @param visible
 * @throws org.openbase.jul.exception.CouldNotPerformException
 */
@Override
public Future<Void> setVisible(final Boolean visible) throws CouldNotPerformException {
    return runTask(() -> {
        if (visible) {
            Screen screen = getScreen();
            Stage stage = getStage();
            stage.setX(screen.getVisualBounds().getMinX());
            stage.setY(screen.getVisualBounds().getMinY());
            stage.setHeight(screen.getVisualBounds().getHeight());
            stage.setWidth(screen.getVisualBounds().getWidth());
            getStage().setFullScreen(false);
            getStage().setAlwaysOnTop(true);
            getStage().setFullScreen(true);
            getStage().show();

        } else {
            getStage().hide();
            getStage().setFullScreen(false);
        }
        return null;
    });
}

From source file:org.jevis.jeconfig.JEConfig.java

/**
 * Build an new JEConfig Login and main frame/stage
 *
 * @param primaryStage//from   ww w.  j  av  a 2s  .  co m
 */
//AITBilal - Login  
private void initGUI(Stage primaryStage) {
    Scene scene;
    LoginGlass login = new LoginGlass(primaryStage);

    AnchorPane jeconfigRoot = new AnchorPane();
    AnchorPane.setTopAnchor(jeconfigRoot, 0.0);
    AnchorPane.setRightAnchor(jeconfigRoot, 0.0);
    AnchorPane.setLeftAnchor(jeconfigRoot, 0.0);
    AnchorPane.setBottomAnchor(jeconfigRoot, 0.0);
    //        jeconfigRoot.setStyle("-fx-background-color: white;");
    //        jeconfigRoot.getChildren().setAll(new Label("sodfhsdhdsofhdshdsfdshfjf"));

    Screen screen = Screen.getPrimary();
    Rectangle2D bounds = screen.getVisualBounds();

    // @AITBilal - Main frame elemente wird aufgerufen nachdem man sich eingeloggt hat.
    login.getLoginStatus().addListener(new ChangeListener<Boolean>() {

        @Override
        public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) {
            if (newValue) {
                System.out.println("after request");
                _mainDS = login.getDataSource();
                ds = _mainDS;

                Platform.runLater(new Runnable() {
                    @Override
                    public void run() {
                        FadeTransition ft = new FadeTransition(Duration.millis(1500), login);
                        ft.setFromValue(1.0);
                        ft.setToValue(0);
                        ft.setCycleCount(1);
                        ft.play();
                    }
                });

                JEConfig.PROGRAMM_INFO.setJEVisAPI(ds.getInfo());
                JEConfig.PROGRAMM_INFO.addLibrary(org.jevis.commons.application.Info.INFO);
                JEConfig.PROGRAMM_INFO.addLibrary(org.jevis.application.Info.INFO);

                preLodedClasses = login.getAllClasses();
                preLodedRootObjects = login.getRootObjects();

                PluginManager pMan = new PluginManager(ds);
                //@AITBilal - Toolbar fr save, newB, delete, sep1, form
                GlobalToolBar toolbar = new GlobalToolBar(pMan);
                pMan.addPluginsByUserSetting(null);

                //                    StackPane root = new StackPane();
                //                    root.setId("mainpane");
                BorderPane border = new BorderPane();
                VBox vbox = new VBox();
                vbox.getChildren().addAll(new TopMenu(), toolbar.ToolBarFactory());
                border.setTop(vbox);
                //@AITBilal - Alle Plugins Inhalt fr JEConfig (Resources... | System | Attribute)
                border.setCenter(pMan.getView());

                Statusbar statusBar = new Statusbar(ds);

                border.setBottom(statusBar);

                System.out.println("show welcome");

                //Disable GUI is StatusBar note an disconnect
                border.disableProperty().bind(statusBar.connectedProperty.not());

                Platform.runLater(new Runnable() {
                    @Override
                    public void run() {
                        AnchorPane.setTopAnchor(border, 0.0);
                        AnchorPane.setRightAnchor(border, 0.0);
                        AnchorPane.setLeftAnchor(border, 0.0);
                        AnchorPane.setBottomAnchor(border, 0.0);

                        jeconfigRoot.getChildren().setAll(border);
                        //                            try {
                        //            WelcomePage welcome = new WelcomePage(primaryStage, new URI("http://coffee-project.eu/"));
                        //            WelcomePage welcome = new WelcomePage(primaryStage, new URI("http://openjevis.org/projects/openjevis/wiki/JEConfig3#JEConfig-Version-3"));

                        //                            Task<Void> showWelcome = new Task<Void>() {
                        //                                @Override
                        //                                protected Void call() throws Exception {
                        try {
                            WelcomePage welcome = new WelcomePage(primaryStage, _config.getWelcomeURL());
                        } catch (URISyntaxException ex) {
                            Logger.getLogger(JEConfig.class.getName()).log(Level.SEVERE, null, ex);
                        } catch (MalformedURLException ex) {
                            Logger.getLogger(JEConfig.class.getName()).log(Level.SEVERE, null, ex);
                        }
                        //                                    return null;
                        //                                }
                        //                            };
                        //                            new Thread(showWelcome).start();

                        //                                WelcomePage welcome = new WelcomePage(primaryStage, _config.getWelcomeURL());
                        //                            } catch (URISyntaxException ex) {
                        //                                Logger.getLogger(JEConfig.class.getName()).log(Level.SEVERE, null, ex);
                        //                            } catch (MalformedURLException ex) {
                        //                                Logger.getLogger(JEConfig.class.getName()).log(Level.SEVERE, null, ex);
                        //                            }
                    }
                });
            }

        }
    });

    AnchorPane.setTopAnchor(login, 0.0);
    AnchorPane.setRightAnchor(login, 0.0);
    AnchorPane.setLeftAnchor(login, 0.0);
    AnchorPane.setBottomAnchor(login, 0.0);
    //@AITBilal - Login Dialog
    scene = new Scene(jeconfigRoot, bounds.getWidth(), bounds.getHeight());
    scene.getStylesheets().add("/styles/Styles.css");
    primaryStage.getIcons().add(getImage("1393354629_Config-Tools.png"));
    primaryStage.setTitle("JEConfig");
    primaryStage.setScene(scene);
    maximize(primaryStage);
    primaryStage.show();

    //        Platform.runLater(new Runnable() {
    //            @Override
    //            public void run() {
    //@AITBilal - Inhalt bzw. die Elemente von LoginDialog
    jeconfigRoot.getChildren().setAll(login);
    //            }
    //        });

    primaryStage.onCloseRequestProperty().addListener(new ChangeListener<EventHandler<WindowEvent>>() {

        @Override
        public void changed(ObservableValue<? extends EventHandler<WindowEvent>> ov,
                EventHandler<WindowEvent> t, EventHandler<WindowEvent> t1) {
            try {
                System.out.println("Disconnect");
                ds.disconnect();
            } catch (JEVisException ex) {
                Logger.getLogger(JEConfig.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    });
}