import javafx.application.Application; import javafx.stage.Stage; import javafx.scene.Scene; import javafx.scene.layout.VBox; import javafx.scene.control.Button; import javafx.scene.control.Label; public class App extends Application { Stage primaryStage; public static void main(String[] args) { launch(args); } @Override public void start(Stage primaryStage) { this.primaryStage = primaryStage; Label label1 = new Label("Első"); Button button1 = new Button("Másik"); VBox vbox1 = new VBox(); vbox1.getChildren().addAll(label1, button1); Scene scene1 = new Scene(vbox1, 300, 250); Label label2 = new Label("Második"); Button button2 = new Button("Vissza"); VBox vbox2 = new VBox(); vbox2.getChildren().addAll(label2, button2); Scene scene2 = new Scene(vbox2, 300, 250); button1.setOnAction(e -> primaryStage.setScene(scene2)); button2.setOnAction(e -> primaryStage.setScene(scene1)); primaryStage.setScene(scene1); primaryStage.show(); } }