Я надеюсь, что я вас понял правильно:
Screen screen = Screen.getPrimary();
Rectangle2D bounds = screen.getVisualBounds();
//let the window use the left half screen:
stage.setX(bounds.getMinX());
stage.setY(bounds.getMinY());
stage.setWidth(bounds.getWidth()/2);
stage.setHeight(bounds.getHeight());
VBox vBox = new VBox();
vBox.setStyle("-fx-background-color: blue;");
Rectangle rect = new Rectangle();
rect.setStyle("-fx-fill: red;");
vBox.getChildren().add(rect);
//not necessary, because always max size (root element of the scene):
//vBox.minWidthProperty().bind(stage.widthProperty());
//vBox.minHeightProperty().bind(stage.heightProperty());
rect.widthProperty().bind(vBox.widthProperty());
rect.heightProperty().bind(vBox.heightProperty().divide(3));
stage.setScene(new Scene(vBox));
stage.show();
При изменении размера окна, то элементы будут автоматически изменять их самостоятельно.
Есть ли способ сделать это, используя размер родительского элемента? –
Это сделано с размером родительского элемента. rect является дочерним элементом vBox, а rect привязывается к размеру vBox. – rbs