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

31
LINES

< > BotCompany Repo | #1006626 // vstackWithSpacing - stack components vertically

JavaX fragment (include) [tags: use-pretranspiled]

Transpiled version (3264L) is out of date.

1  
static int vstackWithSpacing_default = 10;
2  
3  
static JPanel vstackWithSpacing(fL parts) {
4  
  ret vstackWithSpacing(parts, vstackWithSpacing_default);
5  
}
6  
7  
static JPanel vstackWithSpacing(fL parts, final int spacing) {
8  
  ret swing(func -> JPanel {
9  
    JPanel panel = new JPanel(new GridBagLayout);
10  
    new GridBagConstraints gbc;
11  
    gbc.weightx = 1;
12  
    gbc.fill = GridBagConstraints.HORIZONTAL;
13  
    gbc.gridwidth = GridBagConstraints.REMAINDER;
14  
    gbc.insets = new Insets(spacing/2, 0, (spacing+1)/2, 0); // well...
15  
    smartAddWithLayout(panel, gbc, toObjectArray(nonNulls(parts)));
16  
    //gbc = (GridBagConstraints) gbc.clone();
17  
    //gbc.fill = GridBagConstraints.BOTH;
18  
    gbc.weighty = 1;
19  
    gbc.insets = new Insets(0, 0, 0, 0);
20  
    panel.add(jrigid(), gbc);
21  
    ret panel;
22  
  });
23  
}
24  
25  
static JPanel vstackWithSpacing(Component... parts) {
26  
  ret vstackWithSpacing(asList(parts), vstackWithSpacing_default);
27  
}
28  
29  
static JPanel vstackWithSpacing(int spacing, Component... parts) {
30  
  ret vstackWithSpacing(asList(parts), spacing);
31  
}

Author comment

Began life as a copy of #1006475

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1006626
Snippet name: vstackWithSpacing - stack components vertically
Eternal ID of this version: #1006626/12
Text MD5: 0e91b53d3e7fff1f2ae2e3cff562d940
Author: stefan
Category: javax / gui
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-01-05 05:40:04
Source code size: 1056 bytes / 31 lines
Pitched / IR pitched: No / No
Views / Downloads: 746 / 823
Version history: 11 change(s)
Referenced in: [show references]