FlowLayout

A LayoutManager rearranges the components in the container based on their size relative to the size of the container.

Consider the window that just popped up. It's got five buttons of varying sizes. Resize the window and watch how the buttons move. In particular try making it just wide enough so that all the buttons fit on one line. Then try making it narrow and tall so that there's only one button on line. See if you can manage to cover up some of the buttons. Then uncover them. Note that whatever you try to do, the order of the buttons is maintained in a logical way. Button 1 is always before button 2 which is always before button 3 and so on.

It's harder to show, but imagine if the components changed sizes, as they might if you viewed this page in different browsers or on different platforms with different fonts. The layout manager handles all these different cases for you to the greatest extent possible. If you'd used absolute positioning and the window were smaller than expected or the components larger than you expected, some components would likely be truncated or completely hidden. In essence a layout manager defers decisions about positioning until runtime.

elharo@metalab.unc.edu
Previous | Next | Top | Cafe au Lait

Copyright 1997, 1998 Elliotte Rusty Harold
elharo@metalab.unc.edu
Last Modified July 3, 1998