zoukankan      html  css  js  c++  java
  • GridBagLayout的帮助类

    自备详细注释

      1 /*
      2  * To change this license header, choose License Headers in Project Properties.
      3  * To change this template file, choose Tools | Templates
      4  * and open the template in the editor.
      5  */
      6 package swingtest1;
      7 
      8 import java.awt.GridBagConstraints;
      9 import java.awt.Insets;
     10 
     11 /**
     12  * 
     13  * @author DaChongZi
     14  * @param gridx
     15  *            行坐标
     16  * @param gridy
     17  *            列坐标
     18  * @param gridwidth
     19  *            占据多少列
     20  * @param gridheight
     21  *            占据多少行
     22  * @param setAnchor
     23  *            设置单元格内的对齐方式
     24  * @param setFill
     25  *            设置单元格内的填充行为
     26  */
     27 public class GBC extends GridBagConstraints {
     28 
     29     /**
     30      * 设置空间所在网格坐标
     31      * 
     32      * @param gridx
     33      *            横轴坐标
     34      * @param gridy
     35      *            纵轴坐标
     36      */
     37     public GBC(int gridx, int gridy) {
     38     this.gridx = gridx;
     39     this.gridy = gridy;
     40     }
     41 
     42     /**
     43      * 设置控件所在坐标以及需要占用的行列格数
     44      * 
     45      * @param gridx
     46      *            横轴所在坐标
     47      * @param gridy
     48      *            纵轴所在坐标
     49      * @param gridwidth
     50      *            占用行格数
     51      * @param gridheight
     52      *            占用列格数
     53      */
     54     public GBC(int gridx, int gridy, int gridwidth, int gridheight) {
     55     this.gridx = gridx;
     56     this.gridy = gridy;
     57     this.gridwidth = gridwidth;
     58     this.gridheight = gridheight;
     59     }
     60 
     61     /**
     62      * 单元格内的对其方式。
     63      * 绝对位置:east,west,south,north,northeast,northwest,southeast,southwest
     64      * 。默认为center。 相对位置:first_line_start,line_start,first_line_end,page_start
     65      * ,enter,page_end,
     66      * page_end,last_line_start,line_end,last_line_end。默认为center。
     67      * 
     68      * @param anchor
     69      * @return
     70      */
     71     public GBC setAnchor(int anchor) {
     72     this.anchor = anchor;
     73     return this;
     74     }
     75 
     76     /**
     77      * 单元格内的填充行为。 取值为none,both,norizontal,vertical。默认值为none。 * 外部填充
     78      * 如果显示区域比组件的区域大的时候,可以用来控制组件的行为。控制组件是垂直填充,还是水平填充,或者两个方向一起填充。
     79      * 
     80      * @param fill
     81      * @return
     82      */
     83     public GBC setFill(int fill) {
     84     this.fill = fill;
     85     return this;
     86     }
     87 
     88     /**
     89      * 指组件与表格空间四周边缘的空白区域的大小
     90      * 
     91      * @param top
     92      * @param bottom
     93      * @param left
     94      * @param right
     95      * @return
     96      */
     97     public GBC setInsets(int top, int bottom, int left, int right) {
     98     this.insets = new Insets(top, bottom, left, right);
     99     return this;
    100     }
    101 
    102     /**
    103      * 组件的横向、纵向间距
    104      * 
    105      * @param ipadx
    106      * @param ipady
    107      * @return
    108      */
    109     public GBC setIpad(int ipadx, int ipady) {
    110     this.ipadx = ipadx;
    111     this.ipady = ipady;
    112     return this;
    113     }
    114 }
  • 相关阅读:
    sql server 2005 设置用于复制的文本类型大小 [转]
    C#模拟post提交的实现方法
    项目经理角色定位
    无线不能连接 源于Wireless Zero Configuration服务不能自动启动
    软件版本Beta,RC,Demo,Build等是什么意思呢?
    用PUSHD/POPD获得bat文件执行的路径
    Windows下在本机创建SVN服务
    phpAmin如何导入导出大数据文件?
    整理的英语短语
    [转]项目管理心得:一个项目经理的个人体会、经验总结
  • 原文地址:https://www.cnblogs.com/notime/p/3854076.html
Copyright © 2011-2022 走看看