Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is <children> tag useful in fxml? Should it be removed?

IntelliJ checkstyle indicates that this tag should be removed, as it is not required, as in instead of

<VBox>
  <children>
    <HBox>
        ...
    </HBox>
    <HBox>
        ...
    </HBox>
  </children>
</VBox>

you can simply have

<VBox>
  <HBox>
    ...
  </HBox>
  <HBox>
    ...
  </HBox>
</VBox>

This indeed helps not having bloated code at some times, but I failed to find a good reference on a convention here.

This link mentions that the tag is optional as "the loader will automatically add the sub-elements of the VBox to the container's "children" collection". But that doesn't make it very clear if it would be ok to adopt removing this tag from code or not as a convention?

Also, Scene Builder seems to add these tags to newly created controls, but it doesn't mind if you remove them. It does not re-add them while editing such a modified file.

like image 856
Florin Mircea Avatar asked Jul 28 '17 15:07

Florin Mircea


1 Answers

@DefaultProperty a property to which child elements will be added or set when an explicit property is not given. see this

Pane class and all it's subclasses have @DefaultProperty as children see this , so

Is children tag useful in fxml?

i think no , not really

Should it be removed?

it's depend on your preference

like image 196
Ali Faris Avatar answered Oct 17 '22 02:10

Ali Faris