Using the GridBag Customizer
The GridBag customizer enables you to visually adjust the placement and constraints of
components in a GridBagLayout.
 |
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:
-
Add the components you want to use to your form and make sure you have GridBagLayout
set.
-
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 pane.
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.
-
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.
Note, however, that 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 window
more closely reflects how the components will look at runtime.
-
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, Grid Size Buttons.
Set Grid Width and Grid Height to specify how many grid positions are allocated for
the component in each direction. This is the number of cells the component uses,
not the number of pixels. Use an integer value, Remainder (to make the component
the last one in its row or column, using all remaining horizontal or vertical space),
or Relative (to specify that the component be the next to last one in its row or
column).
You can also adjust these settings with the Grid Size buttons. Clicking the rightmost
button with yellow shading sets the value to Remainder.
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.
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.
Internal Padding X and Y, I-Padding Buttons.
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 internal padding buttons.
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.
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.
Legal Notices