📄 e629. setting the location of a component within the cell of a gridbaglayout using anchors.txt
字号:
By default, when the cell is larger than the preferred size of a component, the component is centered within the cell. You can specify other relative positions using the anchor constraint. For example, specifying an anchor of NORTH causes the component to be horizontally centered with the top edge of the component aligned with the top edge of the cell. Specifying an anchor of NORTHEAST causes the northeast corner of the component to coincide with the northeast corner of the cell.
See e622 Creating a GridBagLayout for an example on how to use a gridbag layout with gridbag constraints.
GridBagConstraints gbc = new GridBagConstraints();
// These are the nine possible anchor values
gbc.anchor = GridBagConstraints.CENTER;
gbc.anchor = GridBagConstraints.NORTH;
gbc.anchor = GridBagConstraints.NORTHEAST;
gbc.anchor = GridBagConstraints.EAST;
gbc.anchor = GridBagConstraints.SOUTHEAST;
gbc.anchor = GridBagConstraints.SOUTH;
gbc.anchor = GridBagConstraints.SOUTHWEST;
gbc.anchor = GridBagConstraints.WEST;
gbc.anchor = GridBagConstraints.NORTHWEST;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -