posted 22 years ago
Actually, the API for BoxLayout says -
"BoxLayout attempts to arrange components at their preferred widths (for left to right layout) or heights (for top to bottom layout). For a left to right layout, if not all the components are the same height, BoxLayout attempts to make all the components as high as the highest component."
I think that since the boxes you are adding the components to have an X_AXIS alignment they are honoring the preferred widths of the components only. Then, when you add each of those boxes to the outer Box with a Y_AXIS alignment the outer Box honors the preferred height of the inner Boxes, which is probably set to take up as much space as possible, so the entire size of the outer box is equally divided among the inner boxes... then, since the inner boxes are only honoring preferred width of their components, they make their components height the height of the largest component and this takes up as much possible space on the inside of the inner Boxes.
I would recommend that you use a JPanel with FlowLayout instead of Boxes for the inner Boxes, or change your layout to two vertical boxes rather than four horizontal boxes.
-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.