FirstStyles demonstration

In this demonstration, we will apply a CSS file to a JavaFX application, changing the styles of several buttons and a root node of the scene:

/* chapter6/basics/style.css */.root {     -fx-background-color: lightblue;     -fx-padding: 10px; }.button {     -fx-background-color: white }

Note that all JavaFX CSS properties have the -fx prefix to be clearly distinguished from web CSS ones. JavaFX CSS and web CSS share syntax and property names and look very similar but JavaFX developers deliberately made styles and classes different in order to avoid any compatibility issues. 

JavaFX CSS is described in detail in the JavaFX CSS Reference Guide, which can be found here: https://docs.oracle.com/javase/8/javafx/api/javafx/scene/doc-files/cssref.html ...

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.