Using the GridBag customizer
Forte for Java, Community Edition provides a customizer to simplify the creation of GridBag layouts.
To use the visual GridBag customizer:
- Add the components you want to use and make sure that you have GridBag Layout set.
Note: It is helpful to sketch out the way you want your layout to look before you open the customizer.
- Right-click on the
GridBagLayout
node in the Component Inspector and choose Customize Layout... from the contextual menu, or choose the Customize button on the property sheet pane. The Customizer Dialog will open with a property sheet for GridBag constraints and buttons for adjusting the values of the constraints in its left pane and a rough depiction of the placement of your components on the form in its right pane.![]()
- You can reposition the components in the right pane by dragging them. As you drag the component, its
Grid X
andGrid Y
properties will change to reflect its new position. (Be aware, however, that this panel only serves as a rough 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 Editor window more closely reflects how the components will look.) You can also change these values manually in the left pane.- Once you have the approximate position of the components, you can adjust the other constraints of each component in the left pane. Follow these steps (in whatever order you prefer) to position each component:
- Select a component in the right pane.
- Further adjust its horizontal and vertical position if necessary by setting its X and Y grid positions.
- Adjust the
Grid Width
andGrid Height
parameters to determine how many grid positions are allocated for the component in each direction. The values ofRemainder
(allocates the rest of the space in the given row or column for the component) andRelative
are also available.- You can also adjust these settings with the Grid Width buttons. Pushing the right-most button with yellow shading in each group sets the value to
Remainder
.- Adjust the weight settings of the component to determine how much space it should be given relative to that of the other components. For example, a component with a
Weight X
value of .5 has twice as much horizontal space allotted to it as a component with a value of .25 for this parameter. The sum of the values of the components in a given row or column should not add up to more than one. When a form is resized, these settings affect which components are resized (and by how much). Components with a value of 0 for one of these parameters retain their preferred size for that dimension.- Adjust the insets for the component. The insets determine the amount of free space on each of the four sides of the component.
- You can enter numbers for these manually or use the inset buttons on the bottom part of the left pane. These buttons are divided into four sets. The top group enables you to increase and lower the inset for each side separately. The second group enables you to change the left and right insets simultaneously. The third group lets you change the top and bottom insets simultaneously. The fourth group enables you to change all insets simultaneously.
- As you change the insets, you will see the inset area marked by yellow change in the right pane.
- 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.
- As you adjust these constraints, you can see the selected component in the right pane expand or contract vertically and/or horizontally, according the changes you make.
- The
Fill
constraint enables you to choose whether the component will use all of the vertical and/or horizontal space allocated to it. Any space allocated to a component that the component does not fill is marked with blue in the right pane.- The
Anchor
constraint enables you to place the component in one of nine positions within the space allocated to it (Center
,North
,NorthWest
, and so on). This setting has no effect if there is no free space remaining for the component.
Contents | Prev | Next | Index |