title: how to change parent fxml content from action perform on child fxml component?
body: <p>I created JavaFX application and want to distribute complete functionality among different FXML with hierarchy and MVC structure.</p>
  <p>At the start time RoolLayout.fxml is load which is parent FXML</p>
  <h3>RootLayout.fxml</h3>
  <pre><code>&lt;BorderPane prefHeight=&quot;400.0&quot; prefWidth=&quot;1000.0&quot; xmlns=&quot;http://javafx.com/javafx/8&quot; xmlns:fx=&quot;http://javafx.com/fxml/1&quot; fx:controller=&quot;com.nikunj.drclinic.controller.RootLayoutController&quot;&gt;
  &lt;center&gt;
    &lt;AnchorPane fx:id=&quot;dashboard&quot; BorderPane.alignment=&quot;CENTER&quot; /&gt;
  &lt;/center&gt;
  &lt;top&gt;
    &lt;HBox BorderPane.alignment=&quot;CENTER&quot;&gt;
       &lt;children&gt;
          &lt;fx:include fx:id=&quot;mainMenu&quot; source=&quot;MainMenuBar.fxml&quot; /&gt;
       &lt;/children&gt;
    &lt;/HBox&gt;
  &lt;/top&gt;
  &lt;/BorderPane&gt;
  </code></pre>
  <p>For this used controller is RootLayoutController.java</p>
  <pre><code>public class RootLayoutController {
  
   @FXML
   private MainMenuBarController mainMenuBarController;
  
   @FXML
   private AnchorPane dashboard;
  
   @FXML
   private void initialize() {
      // Initialize the person table with the two columns.
   }
  }
  </code></pre>
  <p>From inside this MainMenuBar.fxml file is also loaded which is child fxml file</p>
  <h3>MainMenuBar.fxml</h3>
  <pre><code>&lt;AnchorPane xmlns=&quot;http://javafx.com/javafx/8&quot; xmlns:fx=&quot;http://javafx.com/fxml/1&quot; fx:controller=&quot;com.nikunj.drclinic.controller.MainMenuBarController&quot;&gt;
     &lt;children&gt;
        &lt;MenuBar layoutY=&quot;2.0&quot; prefWidth=&quot;1000.0&quot; AnchorPane.bottomAnchor=&quot;0.0&quot; AnchorPane.leftAnchor=&quot;0.0&quot; AnchorPane.rightAnchor=&quot;0.0&quot; AnchorPane.topAnchor=&quot;0.0&quot;&gt;
          &lt;menus&gt;
            &lt;Menu mnemonicParsing=&quot;false&quot; text=&quot;File&quot;&gt;
              &lt;items&gt;
                &lt;MenuItem mnemonicParsing=&quot;false&quot; onAction=&quot;#closeApplication&quot; text=&quot;Close&quot; /&gt;
              &lt;/items&gt;
            &lt;/Menu&gt;
            &lt;Menu mnemonicParsing=&quot;false&quot; text=&quot;Patient Detail&quot;&gt;
              &lt;items&gt;
                &lt;MenuItem fx:id=&quot;addPatiendMenuItem&quot; mnemonicParsing=&quot;false&quot; onAction=&quot;#addPatient&quot; text=&quot;Add Patient&quot; /&gt;
                    &lt;MenuItem mnemonicParsing=&quot;false&quot; text=&quot;Find Patient&quot; /&gt;
              &lt;/items&gt;
            &lt;/Menu&gt;
          &lt;/menus&gt;
        &lt;/MenuBar&gt;
     &lt;/children&gt;
  &lt;/AnchorPane&gt;
  </code></pre>
  <p>controller file for this MainMenuBar.fxml is MainMenuBarController.java</p>
  <pre><code>public class MainMenuBarController {
  
   @FXML
   private MenuItem addPatiendMenuItem;
  
   @FXML
   private MenuItem findPatientMenuItem;
  
   @FXML
   public void closeApplication(){
      System.exit(0);
   }
  
   @FXML
   public void addPatient(ActionEvent event){
  
   }
  }
  </code></pre>
  <p>Now on selection of menu item addPatiendMenuItem from controller addPatient(ActionEvent event) method is called.
  From this method how can i change the AnchorPane fx:id = &quot;dashboard&quot; which is component of the parent fxml (RootLayout.fxml) file.</p>
  <p>Suppose i want to load content of third fxml (i.e. Dashboard.fxml) in this AnchorPane, how can i do that?</p>
  <p>I spend lots of hours to find, how to change parent controller component from the action performed on child controller component?</p>