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

ToolBar should have "items" as the DefaultProperty for FXML

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P4 P4
    • None
    • fx2.1
    • javafx

      The following FXML file throws an NPE when parsing:

      <BorderPane id="background" prefWidth="800.0" prefHeight="600.0" xmlns:fx="http://javafx.com/fxml">
          <top>
              <ToolBar>
                  <HBox>
                      <Button text = "Tasks" />
                      <Button text = "Administrator" />
                  </HBox>
              </ToolBar>
          </top>
      </BorderPane>

      I think the problem is that ToolBar doesn't have a @DefaultProperty. I believe the following patch is all that is needed? If this looks right I'm happy to test and apply the patch. I think we also need to improve the error reporting in the FXML parser, it wasn't clear from the NPE error I got what the problem was, so I had to start divide and conquer to find out which part of the FXML file was causing the error.

      diff -r 5fd0bc71c9d6 javafx-ui-controls/src/javafx/scene/control/ToolBar.java
      --- a/javafx-ui-controls/src/javafx/scene/control/ToolBar.java Wed Feb 01 09:34:37 2012 -0500
      +++ b/javafx-ui-controls/src/javafx/scene/control/ToolBar.java Mon Feb 06 10:15:35 2012 -0800
      @@ -29,6 +29,7 @@
       import java.util.Collections;
       import java.util.List;
       
      +import javafx.beans.DefaultProperty;
       import javafx.beans.property.ObjectProperty;
       import javafx.beans.value.WritableValue;
       import javafx.collections.FXCollections;
      @@ -76,7 +77,7 @@
        * </code></pre>
        *
        */
      -
      +@DefaultProperty("items")
       public class ToolBar extends Control {
       
           /***************************************************************************

            rbair Richard Bair (Inactive)
            rbair Richard Bair (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: