title: Scene change vs Pane change
body: <p>I'm relatively new to Java and espacially JavaFX. I'm trying to make a menu, which switches the displayed content on buttonclick. I've done this now by clearing the Pane and asigning a new fxml-file to it. 
  This is one method from my Controller:</p>
  
  <pre><code>protected void CustomStart(ActionEvent event) {
  
          content.getChildren().clear();
          try {
  
              content.getChildren().add(
                      (Node) FXMLLoader.load(getClass().getResource(
                              "/view/CustomStartStructure.fxml")));
          } catch (IOException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          }
      }
  </code></pre>
  
  <p>It works just fine so far but I wuld like to to it by changing the scenes as well.</p>
  
  <p>I want to initiate the scenes whit a fxml-file in the Constructor. It works within another method. But if I try to initiate it in the constructor I get an InvocationTargetException caused by a RuntimeException caused by a StackOverflow error. If I do it in the other method, I get a NullPointerException when I try to change the Scene.</p>
  
  <p>This is the constructor</p>
  
  <pre><code>public Game() throws IOException {
  
          this.MainMenu = new Scene((GridPane) FXMLLoader.load(getClass()
                  .getResource("/view/MainMenuStructure.fxml")), 400, 400);
          this.stage = new Stage();
          this.stage.setScene(MainMenu);
  
      }
  </code></pre>
  
  <p>This is the method in whicht the invocation works:</p>
  
  <pre><code>public void run() throws Exception {
          /**
           * Set the Scenes for the different menus by using the panels from the
           * fxml-files
           */
  
          this.MainMenu = new Scene((GridPane) FXMLLoader.load(getClass()
                  .getResource("/view/MainMenuStructure.fxml")), 400, 400);
          MainMenu.getStylesheets().add(
                  getClass().getResource("/view/MainMenuDesign.css")
                          .toExternalForm());
          this.SingleRaceMenu = new Scene((GridPane) FXMLLoader.load(getClass()
                  .getResource("/view/CustomStartStructure.fxml")), 400, 400);
          /** Giving the Stage a Scene */
          this.setStage(new Stage());
          this.stage.setScene(MainMenu);
          this.stage.show();
  }
  </code></pre>
  
  <p>This is the Buttoncontroller:</p>
  
  <pre><code>protected void CustomStart(ActionEvent event) {
          this.getStage().setScene(getSingleRaceMenu());
  
      }
  </code></pre>
  
  <p>I hope you can give me an advice!</p>