12.13 Nesting Components
Components can be nested. Indeed, because the layout containers are subclasses of Parent, itself a subclass of Node, layout containers are both containers and components. As such, they can contain other layout containers, which in turn can contain components. We can use this feature to achieve more precise layouts.
When nesting components, we usually place several components into a layout container and place that layout container into another layout container. Each layout container can be different so that components can be arranged in many ways. We can even have multiple levels of nesting, as needed.
We illustrate nesting of components in an example where, using three colors (red, green, and blue), we randomly generate ...
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.