Basics of FXML

In FXML, each XML node corresponds to a JavaFX entity:

  • Adding a tag to the FXML file is similar to calling a constructor for a corresponding class.
  • XML attributes correspond to the constructor parameters or setter method calls.
  • For Parent classes, the inner nodes correspond to the children nodes, building hierarchy on the fly.
  • For other classes, the inner nodes correspond to any entities these classes may contain. For example, you can populate FXCollection through FXML.

Let's compare an application and the FXML that describes it. Here is the application:

The FXML that describes it is as follows:

 <?xml version="1.0" encoding="UTF-8"?> ...

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.