12.17 Using a Style Sheet to Style the View

GUI components come with a default style. For example, the background color is white and the text is black. Labels have a rectangular shape, and buttons have a rectangular shape with rounded corners. We can create our own style and customize the look and feel of our application. It is typical to define a style in a separate file, thus separating the contents of the GUI from its style. In this way, it is easier to edit and separately maintain the contents of the GUI and its style; we can modify the style file, also called a style sheet, and the new style is automatically applied to the app.

Earlier in the chapter we introduced CSS. JavaFX supports Cascading Style Sheets (CSS), a language that describes ...

Get Java Illuminated, 5th Edition 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.