Binding window Scene size to Title : Scene « JavaFX « Java






Binding window Scene size to Title

 

import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.layout.BorderPane;
import javafx.stage.Stage;

public class Main extends Application {

  public static void main(String[] args) {
    launch(args);
  }

  @Override
  public void start(Stage primaryStage) {

    BorderPane bp = new BorderPane();
    bp.setPadding(new Insets(10, 50, 50, 50));
    Scene scene = new Scene(bp);
    primaryStage.setScene(scene);
    primaryStage.titleProperty().bind(
        scene.widthProperty().asString().concat(" : ")
            .concat(scene.heightProperty().asString()));
    
    primaryStage.show();
  }
}

   
  








Related examples in the same category

1.Create Scene from VBox
2.Show a Scene
3.Create and Set size and background color for a Scene
4.Set Scene background color and size
5.Not resizable Window Scene
6.Set CSS file to Scene