How to open another window in JavaFX 2?


Question

I have made a simple JavaFX application, but I would like the main window to open a secondary window when the user clicks a button.

What would be the simplest way to accomplish this?

1
14
1/7/2014 8:47:03 AM

Accepted Answer

Button b = new Button();
b.setOnAction(new EventHandler<ActionEvent>() {
    @Override public void handle(ActionEvent e) {
        Stage stage = new Stage();
        //Fill stage with content
        stage.show();
    }
});
30
1/7/2014 8:39:18 AM

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon