Example usage for javafx.stage Stage xProperty

List of usage examples for javafx.stage Stage xProperty

Introduction

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

Prototype

public final ReadOnlyDoubleProperty xProperty() 

Source Link

Usage

From source file:Main.java

@Override
public void start(Stage stage) {
    final Stage stageRef = stage;
    Group rootGroup;// w  ww.j  a v  a  2 s  . c  o  m
    Scene scene = SceneBuilder.create().width(270).height(370)
            .root(rootGroup = GroupBuilder.create()
                    .children(VBoxBuilder.create().layoutX(30).layoutY(20).spacing(10)
                            .children(textStageX = TextBuilder.create().textOrigin(VPos.TOP).build(),
                                    textStageY = TextBuilder.create().textOrigin(VPos.TOP).build(),
                                    textStageW = TextBuilder.create().textOrigin(VPos.TOP).build(),
                                    textStageH = TextBuilder.create().textOrigin(VPos.TOP).build(),
                                    textStageF = TextBuilder.create().textOrigin(VPos.TOP).build())
                            .build())
                    .build())
            .build();

    textStageX.textProperty().bind(new SimpleStringProperty("x: ").concat(stageRef.xProperty().asString()));
    textStageY.textProperty().bind(new SimpleStringProperty("y: ").concat(stageRef.yProperty().asString()));
    textStageW.textProperty()
            .bind(new SimpleStringProperty("width: ").concat(stageRef.widthProperty().asString()));
    textStageH.textProperty()
            .bind(new SimpleStringProperty("height: ").concat(stageRef.heightProperty().asString()));
    textStageF.textProperty()
            .bind(new SimpleStringProperty("focused: ").concat(stageRef.focusedProperty().asString()));
    stage.setResizable(true);

    stage.setScene(scene);
    stage.titleProperty().bind(title);

    stage.show();
}

From source file:acmi.l2.clientmod.l2smr.Controller.java

private void showUmodel(final String obj, final String file) {
    Platform.runLater(() -> {/*from  w w w . ja  v a2 s .co  m*/
        try {
            FXMLLoader loader = new FXMLLoader(getClass().getResource("smview/smview.fxml"));
            loader.load();
            SMView controller = loader.getController();
            controller.setStaticmesh(getStaticMeshDir(), file, obj);
            Scene scene = new Scene(loader.getRoot());
            scene.setOnKeyReleased(controller::onKeyReleased);

            Stage smStage = new Stage();
            smStage.setScene(scene);
            smStage.setTitle(obj);
            smStage.show();

            smStage.setX(Double.parseDouble(L2smr.getPrefs().get("smview.x", String.valueOf(smStage.getX()))));
            smStage.setY(Double.parseDouble(L2smr.getPrefs().get("smview.y", String.valueOf(smStage.getY()))));
            smStage.setWidth(Double
                    .parseDouble(L2smr.getPrefs().get("smview.width", String.valueOf(smStage.getWidth()))));
            smStage.setHeight(Double
                    .parseDouble(L2smr.getPrefs().get("smview.height", String.valueOf(smStage.getHeight()))));

            InvalidationListener listener = observable -> {
                L2smr.getPrefs().put("smview.x", String.valueOf(Math.round(smStage.getX())));
                L2smr.getPrefs().put("smview.y", String.valueOf(Math.round(smStage.getY())));
                L2smr.getPrefs().put("smview.width", String.valueOf(Math.round(smStage.getWidth())));
                L2smr.getPrefs().put("smview.height", String.valueOf(Math.round(smStage.getHeight())));
            };
            smStage.xProperty().addListener(listener);
            smStage.yProperty().addListener(listener);
            smStage.widthProperty().addListener(listener);
            smStage.heightProperty().addListener(listener);
        } catch (IOException e) {
            onException("Couldn't show staticmesh", e);
        }
    });
}