gbc.java

来自「培训时做的学生管理系统.基于J2SE平台开发」· Java 代码 · 共 59 行

JAVA
59
字号
package cn.com.util;

import java.awt.GridBagConstraints;
import java.awt.Insets;
public class GBC extends GridBagConstraints {
	  
	  //设置起始点位置
	  public GBC(int gridx, int gridy) {
	    this.gridx = gridx;
	    this.gridy = gridy;
	  }
	  
	  //起始点位置、所占行数和列数
	  public GBC(int gridx, int gridy, int gridwidth, int gridheight) {
	    this.gridx = gridx;
	    this.gridy = gridy;
	    this.gridwidth = gridwidth;
	    this.gridheight = gridheight;
	  } 
	  
	  //指定其在某一区域内的位置
	  public GBC setAnchor(int anchor) {
	    this.anchor = anchor;
	    return this;
	  }
	  
	  
	  //组件如何拉伸
	  public GBC setFill(int fill) {
	    this.fill = fill;
	    return this;
	  }
	  
	  //如果设置为0则这个区域永远为初始尺寸,建议设置为100,随窗口变化
	  public GBC setWeight(int weightx, int weighty) {
	    this.weightx = weightx;
	    this.weighty = weighty;
	    return this;
	  }
	  
		//用于要求四周空间量相同时使用
	  public GBC setInsets(int distance) {
	    this.insets = new Insets(distance, distance, distance, distance);
	    return this;
	  }
	  
	  //外部填塞,设置组件周围的空间量
	  public GBC setInsets(int top, int left, int bottom, int right) {
		this.insets = new Insets(top, left, bottom, right);
	    return this;
	  }
	  
		//内部填塞,设置组件的最小宽度和高度
	  public GBC setIpad(int ipadx, int ipady) {
	    this.ipadx = ipadx;
	    this.ipady = ipady;
	    return this;
	  }
	}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?