Layout Managers in Visual Composition

Many container components support the use of layout managers. A layout manager is a class that implements the java.awt.LayoutManager or java.awt.LayoutManager2 interface.

You assign a layout manager to the container. In most layouts, you can then define properties for the layout that govern the specifics of the sizing and resizing behavior for the components.

Visual composition makes it easy to try different layouts. If you prefer to lay beans out individually, you can use the null layout setting (that is, no layout) and the Visual Composition Editor alignment tools. For examples of using layout managers, see the com.ibm.ivj.examples.vc.layoutmanagers classes shipped in the IBM Java Examples project.

Supported Layouts

VisualAge supports the use of layout managers in container beans, as follows. For several of these layouts, VisualAge sets layout properties by default.

Alignment tools are disabled for all but null layout.

For examples of using layout managers, see the com.ibm.ivj.examples.vc.layoutmanagers classes shipped in the IBM Java Examples project.

Setting Layout Properties during Visual Composition

For layout manager details, see the Java API documentation.

Consider waiting to set layout properties until you have settled on a layout manager. Many values are lost when you switch layouts or move the component to another container on the free-form surface.

Dropping Beans into the Layout

Once you have assigned a layout, the Visual Composition Editor provides visual cues to help you place beans in the correct position. These cues appear when you place the loaded mouse pointer in position and then press and hold mouse button 1:

For CardLayout, the container is outlined. VisualAge adds beans to the top of the card deck, making the first bean you dropped the bottom card. You can use Switch To on the pop-up menu to move through the deck, or perform tasks on the covered cards in the beans list.

To get access to the layout interface directly, drop a Variable bean on the free-form surface to the right of the container. Change the type of the Variable bean to that of the class implementing the layout manager interface (for example, CardLayout). Connect the layout property of the container bean to the this property of the Variable bean. Then connect to features of the Variable bean.

If you use a layout that allows for a bean to completely cover another bean, the beans list enables you to easily perform tasks on the covered components. To modify bean placement on the Visual Composition Editor from within the beans list, open the Properties for the bean and modify the Constraints.


Related concepts
Visual Composition Editor Overview
Visual Programming Fundamentals
How Classes and Beans Are Related
Visual, Nonvisual, and Composite Beans

Related procedures
Working with Beans Visually
Composing Beans Visually
Adding the IBM Java Examples project
Setting a Layout Manager during Visual Composition
Setting Layout Properties during Visual Composition
GridBag Layout Constraints
Creating a GUI Using GridBagLayout

Related references
Visual Composition Editor
The Menu Bar in Visual Composition
Properties
Pop-Up Menus for the Visual Composition Editor