title: JavaFX Location is not set error message
body: <p>I have problem when trying to close current scene and open up another scene when menuItem is selected. My main stage is coded as below:</p>
  
  <pre><code>public void start(Stage primaryStage) throws Exception {
      primaryStage.setTitle("Shop Management");
      FXMLLoader myLoader = new FXMLLoader(getClass().getResource("cartHomePage.fxml"));
  
      Pane myPane = (Pane) myLoader.load();
  
      CartHomePageUI controller = (CartHomePageUI) myLoader.getController();
  
      controller.setPrevStage(primaryStage);
      Scene myScene = new Scene(myPane);
      primaryStage.setScene(myScene);
      primaryStage.show();
  }
  </code></pre>
  
  <p>When the program is executed, it will go to the cartHomePage.fxml. From there, I can select to go to create product or create category when the menu item is selected. Here is my action event:</p>
  
  <pre><code>Stage prevStage;
  
  public void setPrevStage(Stage stage){
       this.prevStage = stage;
  }
  
   public void gotoCreateCategory(ActionEvent event) throws IOException {
    Stage stage = new Stage();
      stage.setTitle("Shop Management");
      FXMLLoader myLoader = new FXMLLoader(getClass().getResource("createCategory.fxml"));
      Pane myPane = (Pane) myLoader.load();            
      Scene scene = new Scene(myPane);
      stage.setScene(scene);
      prevStage.close();
      setPrevStage(stage);
      stage.show();       
  }
  
  //Method to change scene when menu item create product is on click
  @FXML
  public void gotoCreateProduct(ActionEvent event) throws IOException {
     Stage stage = new Stage();
      stage.setTitle("Shop Management");
      FXMLLoader myLoader = new FXMLLoader(getClass().getResource("creatProduct.fxml"));
      Pane myPane = (Pane) myLoader.load();            
      Scene scene = new Scene(myPane);
      stage.setScene(scene);
      prevStage.close();
      setPrevStage(stage);
      stage.show();      
  }
  </code></pre>
  
  <p>However, I can only switch the stage once. For example, my default page is cartHomePage.fxml. When I run the program, first I go to create product stage. After that, I cannot go to anywhere any more. The error message is:</p>
  
  <pre><code>java.lang.IllegalStateException: Location is not set.
  and Null Pointer Exception
  </code></pre>
  
  <p>I did set the stage after I close it and pass it around. I wonder which part went wrong.</p>
  
  <p>Thanks in advance.</p>