Default properties

In some cases, you can skip declaring properties, such as children:

<?import javafx.scene.layout.*?><?import javafx.scene.control.*?><HBox xmlns:fx="http://javafx.com/fxml" fx:controller="chapter4.includes.FirstController">    <TextField fx:id="textField" />    <Button text="Button" onAction="#btnAction"/></HBox>

The most common properties are marked as default by the JavaFX API, and FXML allows us to skip them to remove obvious parts of the code.

You can detect such properties by looking into JavaDoc or the source code. They are set through the @javafx.beans.DefaultProperty annotation:

@DefaultProperty("children")public class Paneextends Region
Using this annotation, you can set the default property for your own classes as well. ...

Get Mastering JavaFX 10 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.