← Back to Question List
Java Quiz #62
Scene Switching
What happens when the "Go to Page 2" button is clicked?
📄 Code
1// Scene 12VBox layout1 = new VBox();3Button goToPage2 = new Button("Go to Page 2");4layout1.getChildren().add(goToPage2);5Scene scene1 = new Scene(layout1, 400, 300);67// Scene 28VBox layout2 = new VBox();9layout2.getChildren().add(new Label("Welcome to Page 2"));10Scene scene2 = new Scene(layout2, 400, 300);1112goToPage2.setOnAction(e -> primaryStage.setScene(scene2));1314primaryStage.setScene(scene1);15primaryStage.show();