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.
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.
The strategy used by the FlowLayout layout manager is to place components from left to right, top to bottom, ...