package scenes;

import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;

public class SceneSwitching extends Application {
	
	Scene firstScene;
	Scene secondScene;
	
	public static void main(String[] args) {
		launch(args);
	}

	@Override
	public void start(Stage window) throws Exception {
		// make first scene
		Label label1 = new Label("Welcome to the first scene!");
        Button button1 = new Button("Go to scene 2");
        button1.setOnAction(e -> window.setScene(secondScene));
        VBox layout1 = new VBox();
        layout1.setPadding(new Insets(150,150,150,150));
        layout1.getChildren().addAll(label1, button1);
        firstScene = new Scene(layout1);
        
        // make second scene
     	Label label2 = new Label("Welcome to the second scene!");
        Button button2 = new Button("Go back to scene 1");
        button2.setOnAction(e -> window.setScene(firstScene));
        VBox layout2 = new VBox();
        layout2.setPadding(new Insets(50,50,50,50));
        layout2.getChildren().addAll(label2, button2);
        secondScene = new Scene(layout2);

        // Display first scene at the beginning
        window.setScene(firstScene);
        window.setTitle("Switching scenes demo");
        window.show();
	}

}
