Java Reference
In-Depth Information
Figure 10.8
Margins define the range of empty
space around the numbered label
within a component.
10.4.4
Controlling the grid spacing
The properties Horizontal Gap and Vertical Gap control the amount of horizontal
and vertical space between each cell in a container's layout. If a value is set to -1 (the
default), the gap is inherited from the parent container.
10.4.5
Setting container margins
The margins property allows you to add empty space to the inside of a container
element. Depending on how you look at it, you're either adding a margin around
the contents of the container or adding padding to the container itself. You can
independently specify margins for the top, bottom, left side, and right side. Val-
ues for the margin settings can't be negative.
In order to specify a margin, the container must be under layout control, and
it can't be empty. Any margins you add to a container cause its contents to shift in
position accordingly. Regardless of the overall size of the window, the margins
you specify will be honored. In figure 10.8, three nested panels are placed in
three equal columns. Only the margins around their contents differ, causing the
contents to be constrained appropriately.
10.4.6
Setting sizing policies
The horizontal and vertical sizing policies control how the component responds
to its parent container being resized. The acceptable values and their definitions
are as follows:
canShrink —This component's size can be reduced when the parent con-
tainer is resized.
canGrow —This component's size can be increased when the parent con-
tainer is resized.
wantGrow —This component's size can be increased when the parent con-
tainer is resized. wantGrow has a higher priority then canGrow . Should the
two collide, wantGrow is given priority when competing with other compo-
nents' cells.
 
 
 
 
 
 
 
 
 
Search WWH ::




Custom Search