Sizing, aligning, and positioning beans

This section describes the facilities available in the Visual Composition Editor for sizing, aligning, and positioning beans.

Note: Beans that are containers (such as a JApplet or a Frame) have a layout property. This property supports specific layout managers that control the positioning of beans within the container. Using a layout manager is the preferred way to create a user interface. If you use a <null> layout, the Visual Composition Editor provides tools for aligning and positioning beans. After aligning them as you wish, you can convert the <null> layout to GridBagLayout with no obvious change in appearance.

Sizing beans

To size a bean, follow these steps:

  1. Select the bean you want to size. The selection handles display at each corner.
  2. Drag any one of the selection handles using mouse button 1 to adjust the size of the bean.

Before you release the mouse button, an outline of the bean is displayed to show you the new size of the bean.

To size the bean in only one direction, hold down the Shift key while you drag a selection handle in a horizontal or vertical direction.

You can also use the constraints property in the bean's Properties window to size the beans. For more information about Properties windows, see Changing bean properties.

Aligning beans

To align beans with other beans in a <null> layout, follow these steps:

  1. Select the beans you want to align, ensuring that the last bean selected is the bean you want the others to align with.
  2. Select one of the following alignment tools from the tool bar:

    Align Left tool Align Left

    Align Top tool Align Top

    Align Center tool Align Center

    Align Middle tool Align Middle

    Align Right tool Align Right

    Align Bottom tool Align Bottom

Matching the dimensions of another bean

You can size beans to the same width or height as another bean.

  1. Select the beans you want to match, ensuring that the last bean selected is the one you want the others to match.
  2. Select one of the following sizing tools from the tool bar:

    Match Width tool Match Width

    Match Height tools Match Height

You can also match the dimensions of two or more beans by selecting them and then clicking mouse button 2. Select Layout and then Match Size from the pop-up menu that appears. You can select to match Width, Height, or Both.

Distributing beans evenly

To distribute beans evenly within a composite bean that uses <null> layout, follow these steps:

  1. Select the beans you want to distribute evenly.
  2. Select one of the following distribution tools from the tool bar:

    Distribute Horizontally toolDistribute Horizontally

    Distribute Vertically toolDistribute Vertically

To evenly distribute beans within an imaginary bounding box that surrounds the multiple-selected beans, follow these steps:

  1. Multiple-select the beans you want to evenly distribute. A minimum of three beans must be selected.
  2. From the pop-up menu of one of the selected beans, select Layout and then Distribute. Then select one of the following:
    Horizontally In Bounding Box
    Evenly distribute the selected beans within the area bounded by the leftmost edge of the leftmost bean and the rightmost edge of the rightmost bean.
    Vertically In Bounding Box
    Evenly distribute the selected beans within the area bounded by the topmost edge of the topmost bean and bottommost edge of the bottommost bean.

    There are two more selections in Distribute:

    Horizontally In Surface
    Distributes the selected beans in the same way as Distribute Horizontally from the tool bar.
    Vertically In Surface
    Distributes the selected beans in the same way as Distribute Vertically from the tool bar.