Programmatic Versus Declarative Creation of the User Interface

The JavaFX platform provides two complementary ways for creating a UI. In this chapter, we discuss how you can use the Java API to create and populate a UI. This is a convenient way for Java developers who are used to writing code to leverage APIs.

Designers often use graphical tools that allow them to declare rather than program a UI. The JavaFX platform defines FXML, which is an XML-based markup language that can be used to declaratively describe a UI. Furthermore, a graphical tool called SceneBuilder is made available by Oracle, and this tool is capable of working with FXML files. The use of SceneBuilder is demonstrated in Chapter 3.

Note that parts of a UI can be created using the API, where other parts can be created using SceneBuilder. The FXML APIs provide the bridge and the integration glue between the two approaches.