Swing零散记忆

Swing中使用GridBagLayout布局的时候

调整距离边框距离

可以使用fill 属性,搭配insets,类设置距离边框的距离

  this.rulePane = new UIPanel();
  this.rulePane.setName("rulePane");

  GridBagLayout gridbag = new GridBagLayout();
  GridBagConstraints c = new GridBagConstraints();
  this.rulePane.setLayout(gridbag);

  c.fill = GridBagConstraints.BOTH;

  c.ipadx = 18;
  c.insets = new Insets(20, 10, 2, 400);
  
  /*c.anchor = GridBagConstraints.NORTH;
  c.weightx = 2;
  c.weighty = 1;*/

  // 当前集团 TODO
  c.gridwidth = GridBagConstraints.RELATIVE;
  this.rulePane.add(this.getlbGrp(), c);
  c.gridwidth = GridBagConstraints.REMAINDER;
  this.rulePane.add(this.getlbGrpcode(), c);
  // 归零标志
  c.fill = GridBagConstraints.BOTH;
  c.insets = new Insets(2, 10, 2, 400);
  c.gridwidth = GridBagConstraints.RELATIVE;
  this.rulePane.add(this.getlblResetFlag(), c);
  c.gridwidth = GridBagConstraints.REMAINDER;
  this.rulePane.add(this.getcbbResetFlag(), c);
设置有布局的宽高

this.ruleMainPane.setPreferredSize(new Dimension(1001, 330));
GridBagLayout布局

其他的设置宽高
this.ruleTitlePane = new UIPanel();
this.ruleTitlePane.setName("ruleTitlePane");
this.ruleTitlePane.setBorder(new BorderCustomerLine());
this.ruleTitlePane.setLayout(new GridLayout());
this.ruleTitlePane.setBackground(new Color(204, 204, 204));
//Jack
this.ruleTitlePane.setBounds(24, 29, 970, 32);
this.ckbPrefix = new UICheckBox();
this.ckbPrefix.setName("ckbPrefix");
this.ckbPrefix.setText("");
this.ckbPrefix.setHorizontalAlignment(SwingConstants.CENTER);
//Jack
this.ckbPrefix.setBounds(23, 67, 122, 22);
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 翻译自“Collection View Programming Guide for iOS” 0 关于iOS集合视...
    lakerszhy阅读 3,925评论 1 22
  • 官方文档点蓝色文字:UIImage、CIImage、CGImage。 这篇文章是对官方文档的学习笔记,不是翻译,对...
    阿斯兰iOS阅读 6,521评论 1 8
  • 问答题47 /72 常见浏览器兼容性问题与解决方案? 参考答案 (1)浏览器兼容问题一:不同浏览器的标签默认的外补...
    _Yfling阅读 13,806评论 1 92
  • 选择qi:是表达式 标签选择器 类选择器 属性选择器 继承属性: color,font,text-align,li...
    wzhiq896阅读 1,805评论 0 2
  • 选择qi:是表达式 标签选择器 类选择器 属性选择器 继承属性: color,font,text-align,li...
    love2013阅读 2,337评论 0 11