12.1 FlowLayout



So far, all the applets that have been created seem to have laid out their components using some mysterious internal logic. That's because the applet uses a default layout scheme: the FlowLayout. This simply "flows" the components onto the form, from left to right until the top space is full, then moves down a row and continues flowing the components. Here's an example that explicitly (redundantly) sets the layout manager in an applet to FlowLayout and then places buttons on the form. You'll notice that with FlowLayout the components take on their "natural" size. A Button, for example, will be the size of its string.

Case Study: FlowLayout1.java


All components will be compacted to their smallest size in a FlowLayout, so you might get a little bit of surprising behavior. For example, a label will be the size of its string, so right-justifying it yields an unchanged display.


Next Page