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);
最后編輯于
?著作權歸作者所有,轉載或內容合作請聯(lián)系作者
【社區(qū)內容提示】社區(qū)部分內容疑似由AI輔助生成,瀏覽時請結合常識與多方信息審慎甄別。
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發(fā)布,文章內容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關閱讀更多精彩內容

  • 翻譯自“Collection View Programming Guide for iOS” 0 關于iOS集合視...
    lakerszhy閱讀 4,076評論 1 22
  • 官方文檔點藍色文字:UIImage、CIImage、CGImage。 這篇文章是對官方文檔的學習筆記,不是翻譯,對...
    阿斯蘭iOS閱讀 6,729評論 1 8
  • 問答題47 /72 常見瀏覽器兼容性問題與解決方案? 參考答案 (1)瀏覽器兼容問題一:不同瀏覽器的標簽默認的外補...
    _Yfling閱讀 14,170評論 1 92
  • 選擇qi:是表達式 標簽選擇器 類選擇器 屬性選擇器 繼承屬性: color,font,text-align,li...
    wzhiq896閱讀 2,127評論 0 2
  • 選擇qi:是表達式 標簽選擇器 類選擇器 屬性選擇器 繼承屬性: color,font,text-align,li...
    love2013閱讀 2,443評論 0 11

友情鏈接更多精彩內容