title: How do I embed a controller with a new scene in JavaFX
body: <p>I want to open a new scene with a controller but I get an IOException when I put the controller in it.
  This is my method:</p>
  
  <pre><code>private void forgotAccount (ActionEvent event) {
      try {
          Node node = (Node) event.getSource();
          Stage stage = (Stage) node.getScene().getWindow();
          Scene scene = stage.getScene();
          FXMLLoader loader = new FXMLLoader(Login.class.getResource("/mattiashellkvist/forgotAccount.fxml"));
          loader.setController(new ForgotAccountController());
          AnchorPane root = (AnchorPane) loader.load();
          scene.setRoot(root);
          stage.sizeToScene();
      }
      catch (IOException e) {
          System.out.println("Something went wrong");
      }
  }
  </code></pre>