Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Reid Davis
5,140 PointsWhy use the <children> tag?
Rewatching the series, so you probably mentioned this somewhere and I've missed it, but why are you wrapping things in the <children> tags so frequently?
I've loved the concept of FXML but finding concise documentation for it has been frustrating at best...
2 Answers
Rob Bridges
Full Stack JavaScript Techdegree Graduate 35,467 PointsHey Reid, generally we need all of these things wrapped in tags in the XML so that we can modify their behavior and properties.
Is there a specific instance of code that you had in mind that you caused you extra concern?
Maybe I can help out if I saw what instance brought this about.
Reid Davis
5,140 PointsHey Rob, thanks for the reply. I had intended the question to post directly to one of the "Pomodoro" steps of the JavaFX course, but guess I missed on that one.
Here's a sample of the FXML in question. I'm relatively sure it would work without the 'children' tags, and don't really understand the intent or benefit to including them.
<HBox styleClass="buttons">
<children>
<StackPane>
<children>
<StackPane styleClass="nested-action,play">
<children>
<HBox styleClass="svg-container">
<SVGPath styleClass="svg"
content="M1.6 17C1 17 0 16.2 0 15.6V1.3C0 .1 2.2-.4 3.1.4l8.2 6.4c.5.4.8 1 .8 1.7 0 .6-.3 1.2-.8 1.7l-8.2 6.4c-.5.2-1 .4-1.5.4z"/>
</HBox>
<Button text="Resume"/>
</children>
</StackPane>
<StackPane styleClass="nested-action,pause">
<children>
<HBox styleClass="svg-container">
<SVGPath styleClass="svg"
content="M10.2 17c-1 0-1.8-.8-1.8-1.8V1.8c0-1 .8-1.8 1.8-1.8S12 .8 12 1.8v13.4c0 1-.8 1.8-1.8 1.8z" />
<SVGPath styleClass="svg"
content="M10.2 17c-1 0-1.8-.8-1.8-1.8V1.8c0-1 .8-1.8 1.8-1.8S12 .8 12 1.8v13.4c0 1-.8 1.8-1.8 1.8z" />
</HBox>
<Button text="Pause"/>
</children>
</StackPane>
</children>
</StackPane>
<StackPane styleClass="nested-action,restart">
<children>
<HBox styleClass="svg-container">
<SVGPath styleClass="svg"
content="M21 2.9C19.1 1 16.6 0 13.9 0c-1.1 0-2 .9-2 1.9s.9 1.9 2 1.9c1.7 0 3.2.6 4.4 1.8 2.4 2.4 2.4 6.3 0 8.7-1.2 1.2-2.7 1.8-4.4 1.8-1.7 0-3.2-.6-4.4-1.8-1.8-1.8-2.3-4.4-1.4-6.7L9.3 10c.2.4.5.7.9.8.4.1.8.1 1.2-.1.8-.4 1.1-1.3.8-2.1L10 4.3c0-.5-.2-1-.6-1.4l-.1-.1-.1-.2c-.2-.4-.5-.7-.9-.8-.4-.1-.8-.1-1.2.1L.9 4.8C.1 5.2-.2 6.1.2 6.9c.2.4.5.7.9.8.4.1.8.1 1.2-.1l2-.9c-1.2 3.5-.4 7.6 2.4 10.4C8.6 19 11.2 20 13.9 20s5.3-1 7.2-2.9C25 13.2 25 6.8 21 2.9z"/>
</HBox>
<Button text="Restart"/>
</children>
</StackPane>
</children>
</HBox>