1.GridBagLayout
The layout manager is very flexible and GridBagLayout
maintains a dynamic rectangular cell grid for each object;
2. Need to be used in conjunction with its constraint class (Gridbagconstraints class);
3. GridBagLayout
provide a way for the components to be laid out, and the specific constraints are gridbagconstraints to be implemented;
4. Complete a flexible layout manager by invoking the various constraint attribute fields of gridbagconstraints;
5. Grid package layout image is said to be in accordance with the upper left corner as the origin point, the horizontal right is the x-axis positive direction, vertical downward for the y-axis positive direction (such as)
All the constraint properties in the Gridbagconstraints class are listed below:
Gridx,gridy: Used to determine the position of the component in the current coordinate system (x, y);
Gridwidth,gridheight: Determines the number of cells that the component occupies on the x-axis (y-axis),
(the 2 set of properties above determines where the component occupies the coordinate system)
Fill: Fills (used when the component itself is smaller than the display area it occupies)
Ipadx,ipady: Padding (the default size of the component + how many pixels are added to the default size)
Insets: Margin (the distance of the component border from the cell he occupies)
Weightx,weighty: Weights (the default weight is to place more space between the container border and the cell border ), and the larger the weight value, the more space (the component is the distance from the grid to which it occupies ).
Anchor: Represents the absolute alignment in a cell:
There are three forms of alignment: absolute , value relative to direction, value relative to baseline
Absolute Form
NORTH:
Align 中
top
SOUTH:下中
WEST
: left Middle
EAST:右中
NORTHWEST:左上
NORTHEAST:右上
SOUTHWEST:左下
SOUTHEAST:右下
Center: Center Alignment (default)
Java Foundation--gridbaglayout Layout