1 | static JPanel gridLayoutPanel_trackWidth_evenlySpacedCols(final int cols) { |
2 | ret customLayoutPanel_trackWidth(func(Container parent) { |
3 | int gap = 10; |
4 | Dimension size = parent.getSize(); |
5 | int w = max(100, size.width)-gap*2; |
6 | int y = gap; |
7 | LL<Component> rows = groupInFixedSizeRows(parent.getComponents(), cols); |
8 | new L<Int> colWidths; |
9 | for i to cols: |
10 | colWidths.add((i+1)*w/cols-i*w/cols); |
11 | |
12 | for (L<Component> row : rows) { |
13 | int h = 0, x = gap; |
14 | for (Component c : row) h = max(h, c.getPreferredSize().height); |
15 | for i over row: { |
16 | row.get(i).setBounds(x, y, colWidths.get(i)-gap, h); |
17 | x += colWidths.get(i); |
18 | } |
19 | y += h + gap; |
20 | } |
21 | |
22 | ret componentsBoundingSize(parent, gap); |
23 | }); |
24 | } |
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: | #1008612 |
Snippet name: | gridLayoutPanel_trackWidth_evenlySpacedCols |
Eternal ID of this version: | #1008612/1 |
Text MD5: | d1150e1fa731ac711f857e31b4745d4f |
Author: | stefan |
Category: | javax / gui |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2017-05-25 19:09:01 |
Source code size: | 786 bytes / 24 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 572 / 575 |
Referenced in: | [show references] |