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]

Libraryless. Click here for Pure Java version (3264L/21K).

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/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   

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

No comments. add comment

Snippet ID: #1006626
Snippet name: vstackWithSpacing - stack components vertically
Eternal ID of this version: #1006626/11
Text MD5: 964bf55970fee3f5d6c580b8223fb3f1
Transpilation MD5: 1c7f30869e41cc61ee03d41ea9154358
Author: stefan
Category: javax / gui
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-10-27 15:22:42
Source code size: 1052 bytes / 31 lines
Pitched / IR pitched: No / No
Views / Downloads: 414 / 415
Version history: 10 change(s)
Referenced in: [show references]

Formerly at http://tinybrain.de/1006626 & http://1006626.tinybrain.de