Book Image

Mastering JavaFX 10

By : Sergey Grinev
5 (1)
Book Image

Mastering JavaFX 10

5 (1)
By: Sergey Grinev

Overview of this book

: JavaFX 10 is used to create media-rich client applications. This book takes you on a journey to use JavaFX 10 to build applications that display information in a high-performance, modern user interface featuring audio, video, graphics, and animation. Mastering JavaFX 10 begins by introducing you to the JavaFX API. You will understand the steps involved in setting up your development environment and build the necessary dependencies. This is followed by exploring how to work with the assets, modules, and APIs of JavaFX. This book is filled with practical examples to guide you through the major features of JavaFX 10. In addition to this, you will acquire a practical understanding of JavaFX custom animations, merging different application layers smoothly, and creating a user-friendly GUI with ease. By the end of the book, you will be able to create a complete, feature-rich Java graphical application using JavaFX.
Table of Contents (15 chapters)

Tuning min and max size properties

JavaFX provides a convenient approach to component sizes with properties: min, preferred, and max. These values are used by layout managers to represent their children.

Let's take a button, for example. A button's width is governed by the length of the text inside; on the other hand, a button can't outgrow its container so text may be shortened if there is not enough space—these are natural constraints, but you can impose extra ones by setting setMinWidth() and setMaxWidth().

Let's see in code how different size constraints work in JavaFX:

// chapter7/resising/MinMaxSizeDemo.java
Button btnNoMin = new Button("I have no min width");

Button btnMin = new Button("I have min width");
btnMin.setMinWidth(100);

Button btnMax = new Button("I have limited max width");
btnMax.setMaxWidth(140);

Button btnBig...