Choosing a Layout Manager

A layout manager assists you in determining the size and position of the components within a container. Each container type has a default layout manager. BorderLayout is the default layout manager for the JFrame component. BorderLayout divides the container into five sections (north, south, east, west, and center). You will switch to GridLayout, which creates sections equal in size and displays them in the requested numbers of rows and columns.

To change layout managers:

  1. In the Form Editor, click the Layouts tab in the Component Palette.

    The Layouts pane provides access to the layout managers in the Java Foundation Classes (JFC). When you move the pointer over a button in the toolbar, a tool tip displays the name of the layout manager.

  2. In the Layouts pane, click the GridLayout button.
  3. Click anywhere in the Form Designer pane.
  4. In the Component Inspector pane, select GridLayout in the component hierarchy.

    The properties of the layout manager appear in the Properties pane of the Component Inspector.

  5. Select the default value (0) of the Columns property, type 1, and press Enter.
  6. Select the default value (1) of the Rows property, type 2, and press Enter.

    Although the Form Designer does not display a grid, it now contains a single column and two rows.

Next:  Adding a Label and Setting Its Properties
Back:  Creating a Container

Legal Notices