Java Reference
In-Depth Information
Instance Variable
Description
weightx and weighty
Determines how free space is distributed between
components in the container.
anchor
Determines where a component is positioned within the
area allocated to it in the container.
ipadx and ipady
Determines by how much the component size is to be
increased above its minimum size.
fill
Determines how the component is to be enlarged to fill
the space allocated to it.
insets
Specifies the free space that is to be provided around the
component within the space allocated to it in the
container.
That seems straightforward enough. We can now explore the possible values we can set for these and
then try them out.
GridBagConstraints Instance Variables
A component will occupy at least one grid position, or cell , in a container that uses a GridBagLayout
object, but it can occupy any rectangular array of cells. The total number of rows and columns, and thus
the cell size, in the grid for a container is variable, and determined by the constraints for all of the
components in the container. Each component will have a position in the grid plus an area it is allocated
defined by a number of horizontal and vertical grid positions.
Space around component
delivered by
Insets-new insets(5, 10, 15, 20)
grid = 1
grid = 3
Grid cell 0.0
gridwidth = 2
gridheight = 1
Component 1
Component 2
gridheight = 3
gridwidth = 2
gridx = 3
gridy = RELATIVE
Search WWH ::




Custom Search