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

18
LINES

< > BotCompany Repo | #1004433 // hvgrid - make 2-dimensional GridLayout

JavaX fragment (include)

1  
// TODO: all the fringe cases (?)
2  
static <A> JPanel hvgrid(L<L<A>> components) {
3  
  if (empty(components)) ret new JPanel;
4  
  int h = l(components), w = l(first(components));
5  
  new JPanel panel;
6  
  panel.setLayout(new GridLayout(h, w));
7  
  for (L<A> row : components)
8  
    smartAdd(panel, row);
9  
  ret panel;  
10  
}
11  
12  
static <A> JPanel hvgrid(L<L<A>> components, int gap) {
13  
  JPanel panel = hvgrid(components);
14  
  GridLayout g = cast panel.getLayout();
15  
  g.setHgap(gap);
16  
  g.setVgap(gap);
17  
  ret panel;
18  
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1004433
Snippet name: hvgrid - make 2-dimensional GridLayout
Eternal ID of this version: #1004433/1
Text MD5: 890cb4affbb5cde85b57d84e5a062e5b
Author: stefan
Category: javax / gui
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2016-12-25 16:35:02
Source code size: 509 bytes / 18 lines
Pitched / IR pitched: No / No
Views / Downloads: 755 / 716
Referenced in: [show references]