static JPanel gridLayoutPanel_trackWidth_evenlySpacedCols(final int cols) { ret customLayoutPanel_trackWidth(func(Container parent) { int gap = 10; Dimension size = parent.getSize(); int w = max(100, size.width)-gap*2; int y = gap; LL rows = groupInFixedSizeRows(parent.getComponents(), cols); new L colWidths; for i to cols: colWidths.add((i+1)*w/cols-i*w/cols); for (L row : rows) { int h = 0, x = gap; for (Component c : row) h = max(h, c.getPreferredSize().height); for i over row: { row.get(i).setBounds(x, y, colWidths.get(i)-gap, h); x += colWidths.get(i); } y += h + gap; } ret componentsBoundingSize(parent, gap); }); }