title: Calling a method through from another controller JavaFx
body: <p>RootLayoutControl.java</p>
  
  <pre><code>public class RootLayoutController {
  
  private MainApp mainApp;
  
  
   public void setMainApp(MainApp mainApp) {
      // TODO Auto-generated method stub
      this.mainApp = mainApp;
  }
  
  @FXML
  private void handleNew(){
  
  }
  
  @FXML
  private void handleOpen(){
      FileChooser fileChooser = new FileChooser();
  
      //Set extension filter
      ExtensionFilter extFilter = new FileChooser.ExtensionFilter("Image Files", "*.png","*.jpg", "*.jpeg");
  
      fileChooser.getExtensionFilters().add(extFilter);
  
      // Show save file dialog
      File file = fileChooser.showOpenDialog(mainApp.getPrimaryStage());
  
      if(file != null){
          //CALL createImageView(file);
      }
  }
  </code></pre>
  
  <p>MainApp.java</p>
  
  <pre><code>public class MainApp extends Application {
  
   private Stage primaryStage;
   private BorderPane rootLayout;
  
  @Override
  public void start(Stage primaryStage) {
      this.primaryStage = primaryStage;
      this.primaryStage.setTitle("Photo Album");
  
      initRootLayout();
  
      showImageView();
  }
  
  private void showImageView() {
      // TODO Auto-generated method stub
      try {
          // Load person overview.
          FXMLLoader loader = new FXMLLoader();
          loader.setLocation(MainApp.class.getResource("ImageView.fxml"));
          AnchorPane imageOverview = (AnchorPane) loader.load();
  
          ImageViewController controller = loader.getController();
          controller.setMainApp(this);
  
          // Set person overview into the center of root layout.
          rootLayout.setCenter(imageOverview);
      } catch (IOException e) {
          e.printStackTrace();
      }
  }
  
  public Stage getPrimaryStage() {
      return primaryStage;
  }
  
  public static void main(String[] args) {
      launch(args);
  }
  
  public void ShowView(File file) {
      // TODO Auto-generated method stub
  
  }
  </code></pre>
  
  <p>ImageViewController.java</p>
  
  <pre><code>public class ImageViewController {
  
  private MainApp mainApp;
  
  @FXML
  private ImageView imageView;
  
  @FXML
  private TilePane tile;
  
  public void setMainApp(MainApp mainApp) {
      // TODO Auto-generated method stub
      this.mainApp = mainApp;
  }
  
  private ImageView createImageView(File file){
      return imageView;
  }
  </code></pre>
  
  <p>Creating an image gallery, where if I call the method, </p>
  
  <blockquote>
    <p>handleOpen() in RootLayoutController</p>
  </blockquote>
  
  <p>It'll call method, </p>
  
  <blockquote>
    <p>createImageView() in ImageViewController</p>
  </blockquote>
  
  <p>To pass the variable file to it, any suggestions on how do I do it?</p>