Spanning components across GridBagLayout cells

You can drag a component in a GridBagLayout to make it span multiple cells. You can also specify the width and height of a component using Properties view or the Customize Layout window.

By default, when you drop a component into a GridBagLayout, the visual editor sets the x and y values to assign it to a cell. However, two additional constraints available for a component are gridheight and gridwidth, which are properties on the GridBagConstraints object that is instantiated for each component.

To span a component across multiple cells in a GridBagLayout:

  1. Select the component. The component shows a black selection border around it with two green boxes, or handles, on the right and bottom.

    GridBagLayout, spanning cells

  2. Click and drag a handle to span the component across grid cells. The cursor shows the X/Y coordinates for the grid cell where you are spanning to.

    GridBagLayout, spanning cells

  3. Release the mouse button to complete the span. The grid width and grid height constraints are set based on the number of rows or columns you spanned.

    GridBagLayout, spanning cells

Related tasks
Adding or moving components within GridBagLayout
Customizing the layout of components in GridBagLayout

(C) Copyright IBM Corporation 1999, 2004. All Rights Reserved.