public class MainApp extends Application { public Stage primaryStage = new Stage(); ImageView iv1; public void start( Stage primaryStage) { AnchorPane root= new AnchorPane(); Scene scene1 = new Scene(root,600,400); primaryStage.setTitle("SocOpros"); Image img = new Image("bgg.png"); iv1 = new ImageView(); iv1.setImage(img); iv1.setVisible(true); Button btn = new Button("TEST");//ΡΠΎΠ·Π΄Π°Π½ΠΈΠ΅ ΠΊΠ½ΠΎΠΏΠΊΠΈ btn.setVisible(true); btn.setLayoutX(20); btn.setLayoutY(40); root.getChildren().addAll(iv1,btn); btn.setOnAction(new RotateImg());//ΡΡΡΠ°Π½ΠΎΠ²ΠΊΠ° Π΄Π΅ΠΉΡΡΠ²ΠΈΡ Π½Π° ΠΊΠ½ΠΎΠΏΠΊΡ primaryStage.setScene(scene1); primaryStage.show(); } public static void main(String[] args) { launch(args); } public class RotateImg implements EventHandler<ActionEvent>{ @Override public void handle(ActionEvent arg0) { Stage stage = new Stage(); AnchorPane root2= new AnchorPane(); Scene scene2 = new Scene(root2,600,400); stage.setScene(scene2); stage.show(); } } } When you click on the button, a new window appears as needed. But it is also necessary to close the previous window, but I do not know how to make the primary stage a global object, so that it can work with it in the RotateImg method.