@Override
	public void layoutContainer(Container parent) {
		Insets insets = parent.getInsets();
		Dimension parentSize = parent.getSize();

		int useableWidth = parentSize.width - insets.left - insets.right;
		int n = parent.getComponentCount();
		int x = insets.left;
		int y = insets.top;
		if (n == 0) {
			return;
		}

		Component c = parent.getComponent(0);
		Dimension standardSize = computeStandardComponentSize(parent);
		Dimension preferredSize = getPreferredDimensionForComponent(c, standardSize);

		c.setBounds(x, y, preferredSize.width, preferredSize.height);
		x += preferredSize.width + hgap;

		int rowHeight = getStandardComponentHeight(parent);
		int rowWidth = preferredSize.width;

		for (int i = 1; i < n; i++) {
			c = parent.getComponent(i);
			preferredSize = getPreferredDimensionForComponent(c, standardSize);

			// if the current component fits width-wise on the remaining space
			if (rowWidth + hgap + preferredSize.width <= useableWidth) {
				rowWidth += preferredSize.width + hgap;
				c.setBounds(x, y + (rowHeight - preferredSize.height) / 2, preferredSize.width,
					preferredSize.height);
				x += preferredSize.width + hgap;
			}
			else {
				x = insets.left;
				y += rowHeight + vgap;
				rowWidth = preferredSize.width;
				c.setBounds(x, y + (rowHeight - preferredSize.height) / 2, preferredSize.width,
					preferredSize.height);
				x += preferredSize.width + hgap;
			}
		}
	}
@see javax.swing.Scrollable#getScrollableUnitIncrement(java.awt.Rectangle, int, int)
Ghidra/Framework/Docking/src/main/java/docking/widgets/VariableHeightPanel.java