javafx Windows Creating a new Window


To show some content in a new window, a Stage needs to be created. After creation and initialisation show or showAndWait needs to be called on the Stage object:

// create sample content
Rectangle rect = new Rectangle(100, 100, 200, 300);
Pane root = new Pane(rect);
root.setPrefSize(500, 500);

Parent content = root;

// create scene containing the content
Scene scene = new Scene(content);

Stage window = new Stage();

// make window visible;

Note: This code needs to be executed on the JavaFX application thread.