Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

25
LINES

< > BotCompany Repo | #1007331 // hstackWithSpacing function (layout components left to right, try to fill full height, dev.)

JavaX fragment (include)

1  
static int hstackWithSpacing_spacing = 10;
2  
3  
// first part can be spacing value
4  
static JPanel hstackWithSpacing(O... parts) {
5  
  parts = flattenArray2(parts); // allow collections in parameters
6  
  int spacing = hstackWithSpacing_spacing;
7  
  int i = 0;
8  
  if (first(parts) instanceof Int) {
9  
    spacing = toInt(first(parts));
10  
    ++i;
11  
  }
12  
  JPanel panel = new JPanel(new GridBagLayout);
13  
  new GridBagConstraints gbc;
14  
  gbc.weighty = 1;
15  
  gbc.fill = GridBagConstraints.VERTICAL;
16  
  gbc.gridheight = GridBagConstraints.REMAINDER;
17  
  for (; i < l(parts); i++) {
18  
    if (i != 0)
19  
      panel.add(javax.swing.Box.createRigidArea(new Dimension(spacing, 0)), gbc);
20  
    panel.add(wrapForSmartAdd(parts[i]), gbc);
21  
  }
22  
  gbc.weightx = 1;
23  
  panel.add(jrigid(), gbc);
24  
  ret panel;
25  
}

Author comment

Began life as a copy of #1007328

download  show line numbers  debug dex  old transpilations   

Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1007331
Snippet name: hstackWithSpacing function (layout components left to right, try to fill full height, dev.)
Eternal ID of this version: #1007331/9
Text MD5: d5ef2811f181eb284bf29830925ce509
Author: stefan
Category: javax / gui
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-05-06 17:22:51
Source code size: 785 bytes / 25 lines
Pitched / IR pitched: No / No
Views / Downloads: 424 / 483
Version history: 8 change(s)
Referenced in: [show references]