12.6. The BoxLayout Manager

BoxLayout is a new layout manager introduced in the Swing package. It supports arranging components either in a horizontal row (BoxLayout.X_AXIS) or in a vertical column (BoxLayout.Y_AXIS). The BoxLayout managers lays out the components in the same order in which they were added to the Container, left to right for a horizontal layout, and top to bottom for a vertical layout. Resizing the container does not cause the components to relocate.

BoxLayout first attempts to arrange the components at their preferred widths (vertical layout) or preferred heights (horizontal layout). For a vertical layout, if all the components are not the same width, BoxLayout then attempts to expand all the components to the width of the component ...

Get Core Web Programming, Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.