Size of the Controls

Control (or any Region derived class) has three size limitations:

  • minSize: Minimal size
  • prefSize: Preferred size
  • maxSize: Maximal size

Layout managers, while handling their children, try to use their prefSize. If it's not possible, they are obliged to not shrink any child smaller than their minSize and not let them grow bigger than their maxSize.

Controls usually set their prefSize by themselves based on their content.

For example, button prefSize is based on the length of the text inside, minSize is just enough to show ellipsis instead of text, and the maxSize of  Button is similar to prefSize.

Thus, you don't need to care about a size of the Button in the following sample:

        VBox root = new VBox(5); root.setPadding(new ...

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.