Using the GridBag Customizer

The GridBag customizer enables you to visually adjust the placement and constraints of components in a GridBagLayout.

Tip It is helpful to sketch out the way you want your layout to look before you use the GridBag customizer.

To use the GridBag customizer:

  1. Add the components you want to use to your form and make sure you have GridBagLayout set.
  2. Right-click the GridBagLayout node in the Component Inspector and choose Customize from the contextual menu, or click the Customizer button in the property sheet toolbar.

    The Customizer dialog box opens with a property sheet for GridBag constraints, buttons for adjusting the constraints in its left pane, and a rough depiction of the layout of the components in its right pane.

  3. Drag the components in the right pane to reposition them as desired. As you drag a component, its Grid X and Grid Y properties change to reflect its new position.

    The right pane serves only as a rough layout guide and does not reflect the absolute positions of the components. The position of each component is largely governed by other constraints set in the left pane. The Form Designer more closely reflects how the components will look at runtime.

  4. Once you have the approximate layout of the components, adjust the other constraints of each component in the left pane. Select a component in the right pane and set its constraints as desired:

    Grid X and Grid Y.  Fine-tune the component's horizontal and vertical position if necessary by setting its X and Y grid positions.

    Grid Width and Grid Height.  Set Grid Width and Grid Height to specify how many grid positions are allocated for the component in each direction. Specify either:

    You can also adjust Grid Width and Height using the Grid Size buttons. Click the rightmost button with yellow shading to set the value to Remainder.

    Fill.  The Fill constraint enables you to choose whether the component uses all of the vertical or horizontal space (or both) that is allocated to it. Any space allocated to a component that the component does not fill is marked with blue in the right pane.

    Internal Padding X and Y.  The internal padding settings enable you to increase the horizontal and vertical dimensions of the component. You can adjust these by directly entering numbers for the properties or by using the I-Padding buttons.

    Insets.  The Insets determine the minimum amount of external space on each of the four sides of the component. You can enter numbers manually or use the inset buttons. The buttons are divided into four sets that enable you to adjust the insets for each side separately, the left and right insets simultaneously, the top and bottom insets simultaneously, or all four insets simultaneously.

    As you change the insets, you will see the inset area marked by a yellow background in the right pane.

    Anchor.  The Anchor constraint enables you to place the component in one of nine positions within the space allocated to it (Center, North, North-West, and so on). This setting has no effect if there is no free space remaining for the component.

    Weight X and Weight Y.  Adjust the weight settings to determine how much space a component should be given relative to other components in its row or column when the container window is resized. Generally, weight values range from zero to one. Components with larger weight values get more space allocated in their row or column when the window is resized.

    Components with a weight value of zero always retain their preferred size for that dimension. If all the components in a row or column have a weight of zero, any extra space goes to the outer edges of the row or column and the components stay the same size.

See also
GridBagLayout
Setting the Layout Manager
Adding a Component to a Form
Component Inspector
Property Sheet Toolbar

Legal Notices