美文网首页
Swing零散记忆

Swing零散记忆

作者: feiyingmm | 来源:发表于2017-10-24 20:14 被阅读0次

    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);
    

    相关文章

      网友评论

          本文标题:Swing零散记忆

          本文链接:https://www.haomeiwen.com/subject/bmbxpxtx.html