码迷,mamicode.com
首页 > 数据库 > 详细

GridBagLayout的帮助类

时间:2014-07-19 15:24:17      阅读:242      评论:0      收藏:0      [点我收藏+]

标签:style   blog   java   color   os   width   

自备详细注释

  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 }

GridBagLayout的帮助类,布布扣,bubuko.com

GridBagLayout的帮助类

标签:style   blog   java   color   os   width   

原文地址:http://www.cnblogs.com/notime/p/3854076.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!