13.4. The Panel Class

A Panel is a borderless window that can contain GUI controls and nested windows. Like Canvas, a Panel is not a stand-alone window, and you need to place the Panel in an existing window. A Panel has two major purposes:

  1. Grouping or organizing other components. For complex GUI layouts, you may want to break the display into rectangular regions, embedding each in a Panel. Each Panel is then in charge of laying out the components it contains, and the top-level layout simply has to put the panels in the proper positions.

  2. Creating a custom component that requires embedded components.

Default LayoutManager: FlowLayout

Windows that can hold other components (i.e., Containers) use a LayoutManager to help them arrange their components. ...

Get Core Web Programming, Second 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.