13.2 Laying Out Nodes in a Scene Graph

A layout determines the size and positioning of nodes in the scene graph.

Node Size

In general, a node’s size should not be defined explicitly. Doing so often creates a design that looks pleasing when it first loads, but deteriorates when the app is resized or the content updates. In addition to the width and height properties, most JavaFX nodes have the properties prefWidth, prefHeight, minWidth, minHeight, maxWidth and maxHeight that specify a node’s range of acceptable sizes as it’s laid out within its parent node:

  • The minimum size properties specify a node’s smallest allowed size in points.

  • The maximum size properties specify a node’s largest allowed size in points.

  • The preferred size properties ...

Get Java How To Program, Late Objects, 11th 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.