Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8093537

[FXML] "Introduction to FXML" contains false code example

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 8u40
    • 8u20
    • javafx
    • JDK 1.8.0_20, Win 8, 64 Bit

      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."

            jgiles Jonathan Giles
            mkarg Markus Karg
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: