Example usage for javafx.stage Window xProperty

List of usage examples for javafx.stage Window xProperty

Introduction

In this page you can find the example usage for javafx.stage Window xProperty.

Prototype

public final ReadOnlyDoubleProperty xProperty() 

Source Link

Usage

From source file:io.bitsquare.gui.main.overlays.Overlay.java

protected void cleanup() {
    if (centerTime != null)
        centerTime.stop();//from  w  w  w .  j av a 2 s . c  o m

    if (owner == null)
        owner = MainView.getRootContainer();
    Scene rootScene = owner.getScene();
    if (rootScene != null) {
        Window window = rootScene.getWindow();
        if (window != null && positionListener != null) {
            window.xProperty().removeListener(positionListener);
            window.yProperty().removeListener(positionListener);
            window.widthProperty().removeListener(positionListener);
        }
    }
}

From source file:io.bitsquare.gui.main.overlays.Overlay.java

public void display() {
    if (owner == null)
        owner = MainView.getRootContainer();

    if (owner != null) {
        Scene rootScene = owner.getScene();
        if (rootScene != null) {
            Scene scene = new Scene(gridPane);
            scene.getStylesheets().setAll(rootScene.getStylesheets());
            scene.setFill(Color.TRANSPARENT);

            setupKeyHandler(scene);/*  w w w. jav  a 2s.com*/

            stage = new Stage();
            stage.setScene(scene);
            Window window = rootScene.getWindow();
            setModality();
            stage.initStyle(StageStyle.TRANSPARENT);
            stage.show();

            layout();

            addEffectToBackground();

            // On Linux the owner stage does not move the child stage as it does on Mac
            // So we need to apply centerPopup. Further with fast movements the handler loses
            // the latest position, with a delay it fixes that.
            // Also on Mac sometimes the popups are positioned outside of the main app, so keep it for all OS
            positionListener = (observable, oldValue, newValue) -> {
                if (stage != null) {
                    layout();
                    if (centerTime != null)
                        centerTime.stop();

                    centerTime = UserThread.runAfter(this::layout, 3);
                }
            };
            window.xProperty().addListener(positionListener);
            window.yProperty().addListener(positionListener);
            window.widthProperty().addListener(positionListener);

            animateDisplay();
        }
    }
}