一些API:

  • int gridx, gridy:指定单元格的起始行和列。默认值为 0。
  • int gridwidth, gridheight:指定单元格的行和列的范围。默认值为 1。
  • double weightx, weighty:指定单元格扩大的容量。默认值为 0。
  • int anchor:表示组件在单元格内的对其方式。可以选择的绝对位置包括:
NORTHWEST NORTH NORTHEAST
WEST CENTER EAST
SOUTHWEST SOUTH SOUTHEAST

相对位置

FIRST_LINE_START LINE_START FIRST_LINE_END
PAGE_START CENTER PAGE_END
LAST_LINE_START LINE_END LAST_LINE_END

如果你的应用要本地化为从右向左或者从上向下排列文本,就应该使用后者。默认值为 CENTER。

  • int fill:指定组件在单元格内的填充行为,取值为 NONE、BOTH、HORIZONTAL 或者 VERTICAL。默认值为 NONE。
  • int ipadx, ipady:指定组件周围的“内部”填充。默认值为 0。
  • Insets insets:指定组件边框周围的“外部”填充。默认为不填充。
  • GridBagConstraints(int gridx, int gridy, int gridwidth, int gridheight, double weightx, double weighty, int anchor, int fill, Insets insets, int ipadx, int ipady):用参数中给定的所有字段值构造 GridBagConstraints。这个构造器只用于自动代码生成器,因为它会让你的源代码很难阅读。
package gridbag;import java.awt.*;/*** This class simplifies the use of the GridBagConstraints class.* @version 1.01 2004-05-06* @author Cay Horstmann*/
public class GBC extends GridBagConstraints
{/*** Constructs a GBC with a given gridx and gridy position and all other grid* bag constraint values set to the default.* @param gridx the gridx position* @param gridy the gridy position*/public GBC(int gridx, int gridy){this.gridx = gridx;this.gridy = gridy;}/*** Constructs a GBC with given gridx, gridy, gridwidth, gridheight and all* other grid bag constraint values set to the default.* @param gridx the gridx position* @param gridy the gridy position* @param gridwidth the cell span in x-direction* @param gridheight the cell span in y-direction*/public GBC(int gridx, int gridy, int gridwidth, int gridheight){this.gridx = gridx;this.gridy = gridy;this.gridwidth = gridwidth;this.gridheight = gridheight;}/*** Sets the anchor.* @param anchor the anchor value* @return this object for further modification*/public GBC setAnchor(int anchor){this.anchor = anchor;return this;}/*** Sets the fill direction.* @param fill the fill direction* @return this object for further modification*/public GBC setFill(int fill){this.fill = fill;return this;}/*** Sets the cell weights.* @param weightx the cell weight in x-direction* @param weighty the cell weight in y-direction* @return this object for further modification*/public GBC setWeight(double weightx, double weighty){this.weightx = weightx;this.weighty = weighty;return this;}/*** Sets the insets of this cell.* @param distance the spacing to use in all directions* @return this object for further modification*/public GBC setInsets(int distance){this.insets = new Insets(distance, distance, distance, distance);return this;}/*** Sets the insets of this cell.* @param top the spacing to use on top* @param left the spacing to use to the left* @param bottom the spacing to use on the bottom* @param right the spacing to use to the right* @return this object for further modification*/public GBC setInsets(int top, int left, int bottom, int right){this.insets = new Insets(top, left, bottom, right);return this;}/*** Sets the internal padding* @param ipadx the internal padding in x-direction* @param ipady the internal padding in y-direction* @return this object for further modification*/public GBC setIpad(int ipadx, int ipady){this.ipadx = ipadx;this.ipady = ipady;return this;}
}

Java GridBagConstraints的帮助类:GBC相关推荐

  1. java 中常用的类

    java 中常用的类 Math Math 类,包含用于执行基本数学运算的方法 常用API 取整 l  static double abs(double  a) 获取double 的绝对值 l  sta ...

  2. java封装对象实体类_Java 接口自动化系列--实体类之entity封装

    实体包entity下面有4个类,主要存放java对象,每个类必须有私有属性,空参构造,get set方法 具体excel中数据信息见---工具类excel文章 1.API类 解析excel中接口信息的 ...

  3. Java封装OkHttp3工具类

    点击关注公众号,Java干货及时送达  作者:如漩涡 https://blog.csdn.net/m0_37701381 Java封装OkHttp3工具类,适用于Java后端开发者 说实在话,用过挺多 ...

  4. Java中的BigDecimal类你真的了解吗?

    点击上方"方志朋",选择"设为星标" 回复"666"获取新整理的面试资料 作者:HikariCP www.jianshu.com/p/c81 ...

  5. java输入字符串异常_设计一个 Java 程序,自定义异常类,从命令行(键盘)输入一个字符串,如果该字符串值为“XYZ”。。。...

    设计一个 Java 程序,自定义异常类,从命令行(键盘)输入一个字符串,如果该字符串值为"XYZ",则抛出一个异常信息"This is a XYZ",如果从命令 ...

  6. java中随机数怎么定义类_浅析Java中的随机数类

    Java中的随机数是否可以重复?Java中产生的随机数能否可以用来产生数据库主键?带着这个问题,我们做了一系列测试. 1.测试一: 使用不带参数的Random()构造函数 * @author Carl ...

  7. java实验系统常用类,Java的常用系统类

    Java的常用系统类Tag内容描述: 1.Java语言与JBuilder应用初步 第六章 常用的Java系统类,本章要点,字符串类 数值(Number)类及其子类 数组类 集合类 Object类,字符 ...

  8. Java中常用的类及其特点

    Java中的内部类有四种(内部类作用1.封装装类型. 2.直接访问外部类成员. 3.回调.)内部类,方便他们的外部类调用,一般不会被其它类使用,比如事件监听器之类的,外部类刚好继承了一个别的类,如果你 ...

  9. arduino与java,Arduino具有与Java和C语言类似的IDE集成开发环境和图形化编程环境

    Arduino具有与Java和C语言类似的IDE集成开发环境和图形化编程环境 更多相关问题 听力原文:W: Hi, Steve, good to see you are up and around a ...

最新文章

  1. oracle 和sybase比较,oracle和sybase的一些区别
  2. springboot整合vue小试牛刀
  3. 快速排序的实现及优化
  4. String数据类型的应用场景
  5. BZOJ 1079: [SCOI2008]着色方案 记忆化搜索
  6. 现代制造工程笔记01:课程安排
  7. word 代码块_如何优雅的写好 Pythonic 代码?
  8. InnoDB发展历史
  9. Hibernate双向一对一对象关系模型映射
  10. 云账房签约葡萄城,开启 “在线Excel+智能财税” 时代
  11. chrome强烈推荐安装Octotree插件
  12. JAVASE复习计划
  13. 【STM32】时钟相关函数和类型
  14. 2016民用安防2.0时代重新起航
  15. 积分商城有哪些基本的功能呢?
  16. python修改电脑桌面壁纸_python设置windows桌面壁纸的方法
  17. 手动搭建Hadoop环境
  18. Bonobo Git Server 后台服务安装 详细教程
  19. adobe cep html engine 停止工作,ps2019adobe cep html engine应用程序错误怎么办?
  20. 如何看计算机网络中的“节点”和“结点”

热门文章

  1. 昨天521表白失败,我想用Python分析一下...表白记录和聊天记录
  2. 中继误码率 matlab,关于误码率的问题 急!!!!!
  3. Centos服务器时间
  4. java websocket netty_基于netty实现的websocket
  5. Redis添加从节点
  6. SpringSecurity OAuth2四种模式说明
  7. Nginx的root和alias指令
  8. 手写自己的MyBatis框架-支持插件
  9. 注册注解BeanDefinition
  10. BeanFactory作为 IoC 容器示例