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

IntelliJ checkstyle indicates that this tag should be removed as it is not required like instead

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

      

you can just

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

      

It really helps not to have code bloated a few times, but I haven't been able to find a good convention reference here.

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

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

+3


source to share


1 answer


@DefaultProperty

the property to which children will be added or set when no explicit property is set. see this

Pane

and all its subclasses have @DefaultProperty

as children , see this , so

Is the children tag useful in fxml?



I think no, not true

Should it be removed?

it depends on your preference

+2


source







All Articles