Calling a corresponding API method

Don't forget that instead of CSS setStyle(), you can call a corresponding API method. It's the fastest way (performance-wise) to apply a style from Java code because JavaFX doesn't need to spend additional time to parse CSS and style text and then apply the result using Reflection API calls.

The following two methods do the same thing, but the latter one will work faster:

btn.setStyle("-fx-min-height: 50");btn.setMinHeight(50);

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.