admin 管理员组文章数量: 1184232
2023年12月18日发(作者:15位时间戳转换日期格式)
布 局 管 理
1、流式布局 FlowLayout
类 FlowLayout
yout
所有已实现的接口:
LayoutManager, Serializable
字段摘要
static int
CENTER
此值指示每一行组件都应该是居中的。
static int
LEADING
此值指示每一行组件都应该与容器方向的开始边对齐,例如,对于从左到右的方向,则与左边对齐。
static int
LEFT
此值指示每一行组件都应该是左对齐的。
static int
RIGHT
此值指示每一行组件都应该是右对齐的。
static int
TRAILING
此值指示每行组件都应该与容器方向的结束边对齐,例如,对于从左到右的方向,则与右边对齐。
构造方法摘要
FlowLayout()
构造一个新的 FlowLayout,它是居中对齐的,默认的水平和垂直间
隙是 5 个单位。
FlowLayout(int align)
构造一个新的 FlowLayout,它具有指定的对齐方式,默认的水平和
垂直间隙是 5 个单位。
FlowLayout(int align, int hgap, int vgap)
创建一个新的流布局管理器,它具有指定的对齐方式以及指定的水平和垂直间隙。
方法摘要
void
addLayoutComponent(String name, Component comp)
将指定的组件添加到布局中。
getAlignment()
获取此布局的对齐方式。
如果组件将沿其基线垂直对齐,则返回 true。
int
boolean
getAlignOnBaseline()
int
getHgap()
获取组件之间以及组件与 Container 的边之间的水平间隙。
getVgap()
获取组件之间以及组件与 Container 的边之间的垂直间隙。
layoutContainer(Container target)
布置该容器。
返回需要布置
visible 组件的最小维数,该组件包含在指定的目标容器中。
int
void
Dimension
minimumLayoutSize(Container target)
Dimension
preferredLayoutSize(Container target)
给出指定目标容器中的
visible 组件,返回此布局的首选维数。
void
removeLayoutComponent(Component comp)
从布局中移除指定的组件。
setAlignment(int align)
设置此布局的对齐方式。
setAlignOnBaseline(boolean alignOnBaseline)
设置组件是否应该沿着其基线垂直对齐。
setHgap(int hgap)
设置组件之间以及组件与 Container 的边之间的水平间隙。
setVgap(int vgap)
设置组件之间以及组件与 Container 的边之间的垂直间void
void
void
void
隙。
String
toString()
返回此 FlowLayout 对象及其值的字符串表示形式。
从类 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait,
wait, wait
2、边框布局 BorderLayout
类 BorderLayout
Layout
所有已实现的接口:
LayoutManager, LayoutManager2, Serializable
字段摘要
static String
AFTER_LAST_LINE
与 PAGE_END 同义。
static String
AFTER_LINE_ENDS
与 LINE_END 同义。
static String
BEFORE_FIRST_LINE
与 PAGE_START 同义。
static String
BEFORE_LINE_BEGINS
与 LINE_START 同义。
static String
CENTER
中间区域的布局约束(容器中央)。
static String
EAST
东区域的布局约束(容器右边)。
static String
LINE_END
组件出现在布局的行方向的结尾处。
static String
LINE_START
组件出现在布局的行方向的开始处。
static String
NORTH
北区域的布局约束(容器顶部)。
static String
PAGE_END
组件出现在最后一行布局内容之后。
static String
PAGE_START
组件出现在第一行布局内容之前。
static String
SOUTH
南区域的布局约束(容器底部)。
static String
WEST
西区域的布局约束(容器左边)。
构造方法摘要
BorderLayout()
构造一个组件之间没有间距的新边框布局。
BorderLayout(int hgap, int vgap)
构造一个具有指定组件间距的边框布局。
方法摘要
void
addLayoutComponent(Component comp, Object constraints)
使用指定的约束对象将指定组件添加到布局中。
addLayoutComponent(String name, Component comp)
已过时。
由 addLayoutComponent(Component, Object)
取代。
void
Object
getConstraints(Component comp)
获取指定组件的约束
int
getHgap()
返回组件之间的水平间距。
getLayoutAlignmentX(Container parent)
返回沿 x 轴的对齐方式。
getLayoutAlignmentY(Container parent)
返回沿 y 轴的对齐方式。
基于目标 Container 的组件方向,返回给定约束位置对应的组件。
float
float
Component
getLayoutComponent(Container target, Object constraints)
Component
getLayoutComponent(Object constraints)
获取使用给定约束添加的组件。
int
getVgap()
返回组件之间的垂直间距。
invalidateLayout(Container target)
使布局无效,指示如果布局管理器缓存了信息,则应该将其丢弃。
layoutContainer(Container target)
使用此边框布局对容器参数进行布局。
在给出指定目标容器中的组件的前提下,返回此布局的最大尺寸。
void
void
Dimension
maximumLayoutSize(Container target)
Dimension
minimumLayoutSize(Container target)
使用此布局管理器确定 target 容器的最小大小。
Dimension
preferredLayoutSize(Container target)
基于容器中的组件,使用此布局管理器确定 target 容器的首选大小。
void
removeLayoutComponent(Component comp)
从此边框布局中移除指定组件。
setHgap(int hgap)
设置组件之间的水平间距。
setVgap(int vgap)
设置组件之间的垂直间距。
返回此边框布局的状态的字符串表示形式。
void
void
String
toString()
从类 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait,
wait, wait
3、网格布局 GridLayout
类 GridLayout
yout
所有已实现的接口:
LayoutManager, Serializable
构造方法摘要
GridLayout()
创建具有默认值的网格布局,即每个组件占据一行一列。
GridLayout(int rows, int cols)
创建具有指定行数和列数的网格布局。
GridLayout(int rows, int cols, int hgap, int vgap)
创建具有指定行数和列数的网格布局。
方法摘要
void
addLayoutComponent(String name, Component comp)
将具有指定名称的指定组件添加到布局。
getColumns()
获取此布局中的列数。
getHgap()
获取组件之间的水平间距。
getRows()
int
int
int
获取此布局中的行数。
int
getVgap()
获取组件之间的垂直间距。
layoutContainer(Container parent)
使用此布局布置指定容器。
使用此网络布局确定最小大小的容器参数。
void
Dimension
minimumLayoutSize(Container parent)
Dimension
preferredLayoutSize(Container parent)
使用此网格布局确定容器参数的首选大小。
void
removeLayoutComponent(Component comp)
从布局移除指定组件。
setColumns(int cols)
将此布局中的列数设置为指定值。
setHgap(int hgap)
将组件之间的水平间距设置为指定值。
setRows(int rows)
将此布局中的行数设置为指定值。
setVgap(int vgap)
将组件之间的垂直间距设置为指定值。
返回此网格布局的值的字符串表示形式。
void
void
void
void
String
toString()
从类 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait,
wait, wait
4、网格袋布局 GridBagLayout
类 GridBagLayout
gLayout
所有已实现的接口:
LayoutManager, LayoutManager2, Serializable
字段摘要
double[]
columnWeights
此字段保持对列权重的重写。
columnWidths
此字段保持对列最小宽度的重写。
int[]
protected Hashtable nent,GridBagConstraints> 此哈希表维持组件与其网格包约束之间的关联。 protected GridBagConstraidefaultConstraints nts 此字段保持包含默认值的网格包约束实例,因此如果某个组件没有与其相关联的网格包约束,则会分配给该组件一个 defaultConstraints 的副本。 protected GridBagLayoutInlayoutInfo fo 此字段保持网格包的布局信息。 protected static int MAXGRIDSIZE 此字段不再用于保留数组和保持向后兼容性。 MINSIZE 网格包布局可以布置的最小网格。 PREFERREDSIZE 网格包布局可以布置的首选网格大小。 rowHeights 此字段保持对行最小高度的重写。 protected static int protected static int int[] double[] rowWeights 此字段保持对行权重的重写。 构造方法摘要 GridBagLayout() 创建网格包布局管理器。 方法摘要 void addLayoutComponent(Component comp, Object constraints) 使用指定 constraints 对象将指定组件添加到布局中。 addLayoutComponent(String name, Component comp) 无效,因为此布局管理器不使用每组件字符串。 adjustForGravity(GridBagConstraints constraints, Rectangle r) 根据约束几何结构和填充将 x、y、宽度和高度四个字段调整为正确值。 AdjustForGravity(GridBagConstraints constraints, Rectangle r) 此方法已过时,仅为提供向后兼容性;新代码应该调用 adjustForGravity 来代替。 arrangeGrid(Container parent) 布置网格。 ArrangeGrid(Container parent) 此方法已过时,仅为提供向后兼容性;新代码应该调用 arrangeGrid 来代替。 getConstraints(Component comp) 获取指定组件的约束。 getLayoutAlignmentX(Container parent) 返回沿 X 轴的对齐方式。 getLayoutAlignmentY(Container parent) 返回沿 y 轴的对齐方式。 void protected void protected void protected void protected void GridBagConstraints float float int[][] getLayoutDimensions() 确定布局网格的列宽度和行高度。 protected GridBagLayougetLayoutInfo(Container parent, int sizeflag) tInfo 为当前受管子级的集合填充 GridBagLayoutInfo 的实例。 protected GridBagLayouGetLayoutInfo(Container parent, int sizeflag) tInfo 此方法已过时,仅为提供向后兼容性;新代码应该调用 getLayoutInfo 来代替。 Point getLayoutOrigin() 在目标容器的图形坐标空间确定布局区域的原点。 getLayoutWeights() 确定布局网格的行与列的权重。 基于 getLayoutInfo 中的信息计算其所有者的最小大小。 double[][] protected Dimension getMinSize(Container parent, GridBagLayoutInfo info) protected Dimension GetMinSize(Container parent, GridBagLayoutInfo info) 此方法已过时,仅为提供向后兼容性;新代码应该调用 getMinSize 来代替。 void invalidateLayout(Container target) 使布局失效,指示如果布局管理器缓存了信息,则应该将其丢弃。 layoutContainer(Container parent) 使用此网格包布局布置指定容器。 location(int x, int y) 确定在布局网格中哪个单元包含由 (x, y) 指定的点。 void Point protected GridBagConstlookupConstraints(Component comp) raints 检索指定组件的约束。 Dimension maximumLayoutSize(Container target) 在给出指定目标容器中的组件的前提下,返回此布局的最大维数 minimumLayoutSize(Container parent) 使用此网格包布局确定 parent 容器的最小大小。 preferredLayoutSize(Container parent) 使用此网络包布局确定 parent 容器的首选大小。 removeLayoutComponent(Component comp) 从此布局移除指定组件。 setConstraints(Component comp, Dimension Dimension void void GridBagConstraints constraints) 设置此布局中指定组件的约束条件。 String toString() 返回此网格包布局的值的字符串表示形式。 从类 继承的方法 clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
版权声明:本文标题:JAVA SWING 4中布局方式 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.roclinux.cn/p/1702889451a434816.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论