Java Foundation--gridbaglayout Layout

Source: Internet
Author: User

1.GridBagLayoutThe 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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.