Leaving Positioning to Layout Managers
The best way to position and size components is to have a layout manager do it for you. The package java.awt contains the classes for performing the layout of GUI components on the screen and for creating, manipulating and interrogating the layout of those components. The java.awt package provides five layout managers: FlowLayout, BorderLayout, GridLayout, CardLayout, and GridBagLayout.
Note
Unlike most AWT classes, the layout manager classesinherit directly from Object rather than from java.awt.Component.
The following sections show examples of how to use each layout manager.
FlowLayout Code Example
The strategy used by the FlowLayout layout manager is to place components from left to right, top to bottom, ...
Get PURE Java™ 2 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.