Creating a type-safe UI versus FXML

As we mentioned previously, JavaFX offers two ways of building the UI—Java code and FXML.

The former is a type-safe way of building the UI. However, Java code is quite verbose and does not bring out the hierarchy of UI controls. In other words, it is not expressive enough. This is one of the major reasons that FXML is preferred in the JavaFX world.

TornadoFX turns this argument upside down. It utilizes Kotlin's expressive power to make the UI hierarchy explicit by looking at the code. It also brings the concept of builders, which leverage Kotlin's functional programming support and extension functions to produce UI code that is structured and easy to read. While the builders can be used with all controls, ...

Get Kotlin Blueprints 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.