Referring to CSS styles from FXML

CSS styles and style sheets can be set used in FXML too. We briefly looked at this in Chapter 4, FXML, while talking about SceneBuilder.

Take a look at the following FXML code and three ways to use styles directly in the FMXL:

<!-- Setting a Style Class --><Button styleClass="my-button" /><!-- Setting a style --><Button style="-fx-min-height: 50" /><!-- Setting a whole stylesheet --><GridPane stylesheets="@style.css" />

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.