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 main window, 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 Editor window.

    The Form Editor changes to display a grid three columns wide by two rows deep.

  4. In the Component Inspector window, select GridLayout.

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

  5. Select the default value (3) of the Columns property, type 1, and press Enter.

    The Form Editor now displays a grid with one column and two rows.

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

Legal Notices