// currently doesn't use any gaps or margins sclass VScrollingWrapLayout > AbstractLayoutManager { //settable bool centeredHorizontally; // TODO public void layoutContainer(Container parent) { L components = getComponents(parent); int maxWidth = parent.getWidth(); int x = 0, y = 0; int lineHeight = 0; int componentsInLine = 0; for (c : components) { Dimension size = c.getPreferredSize(); bool needNewLine = componentsInLine != 0 && x+size.width > maxWidth; if (needNewLine) { y += lineHeight; x = componentsInLine = lineHeight = 0; } c.setBounds(x, y, size.width, size.height); x += size.width; lineHeight = max(size.height, lineHeight); ++componentsInLine; } preferredSize(maxWidth, y+lineHeight); } }