云题海 - 专业文章范例文档资料分享平台

当前位置:首页 > GridBagLayout(网格布局管理器)结构分析与功能使用详解

GridBagLayout(网格布局管理器)结构分析与功能使用详解

  • 62 次阅读
  • 3 次下载
  • 2025/12/9 5:16:34

c.fill = GridBagConstraints.BOTH; c.weightx = 1.0;

makebutton(\ makebutton(\ makebutton(\

c.gridwidth = GridBagConstraints.REMAINDER; //end row

makebutton(\

c.weightx = 0.0; //reset to the default

makebutton(\

c.gridwidth = GridBagConstraints.RELATIVE; //next-to-last in row

makebutton(\

c.gridwidth = GridBagConstraints.REMAINDER; //end row

makebutton(\

c.gridwidth = 1; //reset to the default

c.gridheight = 2; c.weighty = 1.0;

makebutton(\

c.weighty = 0.0; //reset to the default

c.gridwidth = GridBagConstraints.REMAINDER; //end row

c.gridheight = 1; //reset to the default

makebutton(\ makebutton(\

setSize(300, 100); }

public static void main(String args[]) {

Frame f = new Frame(\ GridBagEx1 ex1 = new GridBagEx1();

ex1.init();

f.add(\ f.pack();

f.setSize(f.getPreferredSize()); f.show(); } }

从以下版本开始:

JDK1.0 另请参见:

GridBagConstraints, GridBagLayoutInfo, ComponentOrientation, 序列化表格

字段摘要 double[] columnWeights 此字段保持对列权重的重写。 columnWidths 此字段保持对列最小宽度的重写。 comptable 此哈希表维持组件与其网格包约束之间的关联。 int[] protected Hashtable protected GridBagdefaultConstraints Constraints 此字段保持包含默认值的网格包约束实例,因此如果某个组件没有与其相关联的网格包约束,则会分配给该组件一个 defaultConstraints 的副本。 layoutInfo LayoutInfo 此字段保持网格包的布局信息。 protected MAXGRIDSIZE static int protected GridBag 此字段不再用于保留数组和保持向后兼容性。 网格包布局可以布置的最小网格。 网格包布局可以布置的首选网格大小。 rowHeights 此字段保持对行最小高度的重写。 rowWeights protected MINSIZE static int protected PREFERREDSIZE static int int[] double[] 此字段保持对行权重的重写。

构造方法摘要 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 来代替。 void protected void protected void protected void protected void GridBagConstraintgetConstraints(Component comp) s 获取指定组件的约束。 getLayoutAlignmentX(Container parent) 返回沿 X 轴的对齐方式。 getLayoutAlignmentY(Container parent) 返回沿 y 轴的对齐方式。 getLayoutDimensions() float float int[][] 确定布局网格的列宽度和行高度。 protected GridBaggetLayoutInfo(Container parent, int sizeflag) LayoutInfo 为当前受管子级的集合填充 GridBagLayoutInfo 的实例。 GetLayoutInfo(Container parent, int sizeflag) LayoutInfo 此方法已过时,仅为提供向后兼容性;新代码应该调用 getLayoutInfo 来代替。 Point protected GridBaggetLayoutOrigin() 在目标容器的图形坐标空间确定布局区域的原点。 getLayoutWeights() 确定布局网格的行与列的权重。 double[][] protected DimensigetMinSize(Container parent, GridBagLayoutInfo info) on 基于 getLayoutInfo 中的信息计算其所有者的最小大小。 GetMinSize(Container parent, GridBagLayoutInfo info) on 此方法已过时,仅为提供向后兼容性;新代码应该调用 getMinSize 来代替。 invalidateLayout(Container target) 使布局失效,指示如果布局管理器缓存了信息,则应该将其丢弃。 layoutContainer(Container parent) 使用此网格包布局布置指定容器。 location(int x, int y) 确定在布局网格中哪个单元包含由 (x, y) 指定的点。 protected Dimensi void void Point protected GridBaglookupConstraints(Component comp) Constraints 检索指定组件的约束。 Dimension maximumLayoutSize(Container target) 在给出指定目标容器中的组件的前提下,返回此布局的最大维数 minimumLayoutSize(Container parent) 使用此网格包布局确定 parent 容器的最小大小。 preferredLayoutSize(Container parent) 使用此网络包布局确定 parent 容器的首选大小。 removeLayoutComponent(Component comp) Dimension Dimension void

  • 收藏
  • 违规举报
  • 版权认领
下载文档10.00 元 加入VIP免费下载
推荐下载
本文作者:...

共分享92篇相关文档

文档简介:

c.fill = GridBagConstraints.BOTH; c.weightx = 1.0; makebutton(\ makebutton(\ makebutton(\ c.gridwidth = GridBagConstraints.REMAINDER; //end row makebutton(\ c.weightx = 0.0; //reset to the default makebutton(\ c.gridwidth = GridBagConstraints.REL

× 游客快捷下载通道(下载后可以自由复制和排版)
单篇付费下载
限时特价:10 元/份 原价:20元
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:fanwen365 QQ:370150219
Copyright © 云题海 All Rights Reserved. 苏ICP备16052595号-3 网站地图 客服QQ:370150219 邮箱:370150219@qq.com