Using static methods in FXML

Some JavaFX APIs require the use of static methods, like those we used to adjust BorderPane in Chapter 1, Stages, Scenes, and Layout:

BorderPane.setAlignment(label, Pos.CENTER);

To use them in FXML, you need to call them backward—inside a parameter to be adjusted, you need to assign a value to the class name and property name combination—BorderPane.alignment="CENTER".

Here is a full example of such FXML (note another example of using define, adding it to make an image look better):

<?import javafx.scene.control.*?><?import javafx.scene.layout.*?><?import javafx.geometry.*?><BorderPane padding="$insets" xmlns:fx="http://javafx.com/fxml/1">    <fx:define> <Insets bottom="5.0" left="5.0" right="5.0" top="5.0" fx:id=" ...

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.