当前位置:首页 > GridBagLayout(网格布局管理器)结构分析与功能使用详解
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
构造方法摘要 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
共分享92篇相关文档