The "Nested Controllers" example in http://docs.oracle.com/javafx/2/api/javafx/fxml/doc-files/introduction_to_fxml.html#nested_controllers is wrong: When really trying to have an <fx:include> OUTSIDE of <fx:define>, and that included FXML describes A DIALOG then what you effectively get is an error message at runtime: Caused by: java.lang.IllegalArgumentException: MyPane[id=dialog]is already inside a scene-graph and cannot be set as root.
So to make the example work, it must have <fx:include> wrapped within <fx:define> to prevent addition of the dialog defined by dialog.fxml to the scene graph defined by main_window_content.fxml!
It is very confusing to FXML beginners, so this doc should get fixed ASAP. The optimal fix not only adds the <fx:define> wrapping, but also explains the need for this in a short sentence like: "As the content of the file referenced by fx:include otherwise would become part of the scene graph spanned from main_window_content.fxml, it is needed to wrap fx:include by fx:define to separate the scene graphs of both windows."
So to make the example work, it must have <fx:include> wrapped within <fx:define> to prevent addition of the dialog defined by dialog.fxml to the scene graph defined by main_window_content.fxml!
It is very confusing to FXML beginners, so this doc should get fixed ASAP. The optimal fix not only adds the <fx:define> wrapping, but also explains the need for this in a short sentence like: "As the content of the file referenced by fx:include otherwise would become part of the scene graph spanned from main_window_content.fxml, it is needed to wrap fx:include by fx:define to separate the scene graphs of both windows."