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.

static int vstackWithSpacing_default = 10;

static JPanel vstackWithSpacing(fL parts) {
  ret vstackWithSpacing(parts, vstackWithSpacing_default);
}

static JPanel vstackWithSpacing(fL parts, final int spacing) {
  ret swing(func -> JPanel {
    JPanel panel = new JPanel(new GridBagLayout);
    new GridBagConstraints gbc;
    gbc.weightx = 1;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    gbc.insets = new Insets(spacing/2, 0, (spacing+1)/2, 0); // well...
    smartAddWithLayout(panel, gbc, toObjectArray(nonNulls(parts)));
    //gbc = (GridBagConstraints) gbc.clone();
    //gbc.fill = GridBagConstraints.BOTH;
    gbc.weighty = 1;
    gbc.insets = new Insets(0, 0, 0, 0);
    panel.add(jrigid(), gbc);
    ret panel;
  });
}

static JPanel vstackWithSpacing(Component... parts) {
  ret vstackWithSpacing(asList(parts), vstackWithSpacing_default);
}

static JPanel vstackWithSpacing(int spacing, Component... parts) {
  ret vstackWithSpacing(asList(parts), spacing);
}

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: 747 / 823
Version history: 11 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)
#1014635 - DynamicVStack - stack components vertically with simple add/removal
#1034304 - vstackWithSpacing_fixed - stack components vertically. fixed top margin