Using the FlowLayout Manager
FlowLayout draws components from left to right as they are added to the container. If a component will not fit on a row, a new row is added and the component is placed there, going from top to bottom. Each component takes on its preferredSize. For example, a JButton sizes to the width of text placed within it. FlowLayout provides a simple layout manager that is used, by default, for JPanels. For a demonstration of the layout manager’s rules, see Figure 12.4.
Figure 12.4. FlowLayout goes from left to right displaying components.
NOTE
If you want to have a horizontal FlowLayout, use the layout manager HorizontalFlowLayout ...
Get Borland® JBuilder™ Developer’s Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.