Setting the Layout Manager

Containers are created with default layout managers. Most use BorderLayout by default. Panels use FlowLayout by default.

Layout managers do not apply to all containers. For example, ScrollPane, JScroll Pane, JTabbedPane, JDesktopPane, and JSplitPane have their own special layouts that cannot be changed.

You can change the layout manager of most containers using the component palette, Form window, or Component Inspector.

To set the layout manager using the component palette:

  1. Select the desired layout in the Layouts tab of the component palette.

    If you are not yet familiar with the icons that represent the various layout managers, move the pointer over each image to see the tool tips.

  2. On the Form window, click inside the container whose layout you want to change.

To set the layout manager using the Form window or Component Inspector:

  1. Select the target container. Right-click the component in the Form window or the node for the container in the Component Inspector.

  2. From the contextual menu, choose the desired layout from the Set Layout submenu.

When you change layouts, the IDE remembers the properties of the discarded layout manager. If you change the layout manager back, the component looks the same as it previously looked with that layout manager.

The only exception can happen when you switch from AbsoluteLayout to GridBagLayout. In this case, the new properties are created such that GridBagLayout looks as close as possible to the previous AbsoluteLayout. Therefore, any previous GridBagLayout property settings are lost.

See also
Component Palette

Setting Layout Properties

Standard Layout Managers

Legal Notices