title: Swap JavaFX scene when clicking a button
body: <p>I am trying to create a program to teach people about GNU/Linux and the command line, I have my main.java</p>
  
  <pre><code>package sample;
  
  import javafx.application.Application;
  import javafx.fxml.FXMLLoader;
  import javafx.scene.Parent;
  import javafx.scene.Scene;
  import javafx.stage.Stage;
  
  public class Main extends Application {
      Stage window;
  
      public static void main(String[] args) {
          launch(args); 
      }
  
      @Override
      public void start(Stage primaryStage) throws Exception {
          window = primaryStage;
          Parent root = FXMLLoader.load(getClass().getResource("login.fxml"));
          primaryStage.setTitle("Learnix");
          primaryStage.setScene(new Scene(root, 800, 500));
          primaryStage.show();
      }
  }
  </code></pre>
  
  <p>And the controller to go with it. </p>
  
  <pre><code>package sample;
  import javafx.fxml.FXMLLoader;
  import javafx.scene.Parent;
  import javafx.scene.Scene;
  import javafx.scene.control.Button;
  import java.io.IOException;
  
  public class loginController {
      public Button loginBtn;
      public void loginBtnClick() throws IOException {
          System.out.println("You are logged in");
       }
  }
  </code></pre>
  
  <p>I have tried things such as:</p>
  
  <pre><code>FXMLLoader.load(getClass().getResource("lessons.fxml"));
  </code></pre>
  
  <p>But I can't figure out how to get it to swap scenes. I have seen many tutorials on YouTube and it Stack Overflow but many of them have all of the JavaFX on the <code>main.java</code> and not in separate files as I am using scenebuilder.</p>
  
  <p>Thank you.</p>