BoxLayouts in Java 2
Like the other layout managers, you can setLayout of a panel to be a BoxLayout, but in addition, there is a special container called Box whose default layout is a vertical or horizontal box layout: Box b = Box.createHorizontalBox ( );or Box b = Box. createVericalBox ( );
You can add components in the usual way and they are flowed into the one dimension, where the size strategy is to make them fit into one row or column, using the preferred size if possible (and alignment), but growing them to maximum size if necessary.
There are invisible fillers available to space the components.