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

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

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 8u20
    • Fix Version/s: 8u40
    • Component/s: javafx
    • Labels:
    • Environment:

      JDK 1.8.0_20, Win 8, 64 Bit

    • Subcomponent:

      Description

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

        Attachments

          Activity

            People

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

              Dates

              • Created:
                Updated:
                Resolved:
                Imported: