Type-safe styling

We saw earlier that JavaFX advocates the use of CSS (Cascading Style Sheets) to style the controls. While this is consistent with the web way of styling, it can be improved upon by using the type-safe CSS option provided by Tornado FX. In this way, the styles are expressed in pure Kotlin code instead of CSS.

You may notice that this is nothing but a Domain Specific Language (DSL), which is possible in Kotlin because of its expressiveness.

A DSL is a language that is highly readable for the functional experts belonging to a domain. For example, a DSL may be used to define the UI (for the UI experts), and another DSL may be used to define test cases (for the testing experts). DSL uses the vocabulary of the underlying domain, ...

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.