package com.agfa.modules.gridpath.fx; import javafx.application.Application; import javafx.beans.value.ChangeListener; import javafx.beans.value.ObservableValue; import javafx.geometry.Insets; import javafx.scene.Scene; import javafx.scene.control.Label; import javafx.scene.control.TextField; import javafx.scene.layout.BorderPane; import javafx.scene.layout.FlowPane; import javafx.scene.layout.GridPane; import javafx.scene.layout.StackPane; import javafx.scene.paint.Color; import javafx.stage.Stage; public class SimpleSizeMonitorApplication extends Application { public static void main(String[] args) { launch(args); } @Override public void start(Stage primaryStage) { BorderPane pane = new BorderPane(); GridPane leftPane = new GridPane(); leftPane.setStyle("-fx-background-color: burlywood;"); leftPane.setHgap(5.0d); leftPane.setVgap(5.0d); leftPane.setPadding(new Insets(5.0d)); BorderPane mainContent = new BorderPane(); mainContent.setCenter(new Label("RESIZE ME...")); mainContent.setStyle("-fx-background-color: coral;"); final TextField mainContentHeightTF = new TextField(); final TextField mainContentWidthTF = new TextField(); final TextField mainContentSemiWidthTF = new TextField(); final TextField mainContentSemiHeightTF = new TextField(); mainContent.widthProperty().addListener(new ChangeListener() { public void changed(ObservableValue observable, Number oldValue, Number newValue) { mainContentWidthTF.setText("" + newValue); } }); mainContent.widthProperty().divide(2).addListener(new ChangeListener() { public void changed(ObservableValue observable, Number oldValue, Number newValue) { mainContentSemiWidthTF.setText("" + newValue); } }); mainContent.heightProperty().addListener(new ChangeListener() { public void changed(ObservableValue observable, Number oldValue, Number newValue) { mainContentHeightTF.setText("" + newValue); } }); mainContent.heightProperty().divide(2).addListener(new ChangeListener() { public void changed(ObservableValue observable, Number oldValue, Number newValue) { mainContentSemiHeightTF.setText("" + newValue); } }); leftPane.add(new Label("width"), 0, 0); leftPane.add(mainContentWidthTF, 1, 0); leftPane.add(new Label("height"), 0, 1); leftPane.add(mainContentHeightTF, 1, 1); leftPane.add(new Label("semi-width"), 0, 2); leftPane.add(mainContentSemiWidthTF, 1, 2); leftPane.add(new Label("semi-height"), 0, 3); leftPane.add(mainContentSemiHeightTF, 1, 3); pane.setLeft(leftPane); pane.setCenter(mainContent); Scene scene = new Scene(pane, 800, 800, Color.WHITE); primaryStage.setScene(scene); primaryStage.show(); } }