Here you can find the source of singleColumn(final Container container, final int initialY, final int yPad)
public static void singleColumn(final Container container, final int initialY, final int yPad)
//package com.java2s; //License from project: Apache License import java.awt.Component; import java.awt.Container; import javax.swing.Spring; import javax.swing.SpringLayout; import javax.swing.SpringLayout.Constraints; public class Main { public static void singleColumn(final Container container, final int initialY, final int yPad) { Spring height = Spring.constant(initialY + yPad * container.getComponentCount()); Spring width = Spring.constant(0); final SpringLayout layout = (SpringLayout) container.getLayout(); Component previous = container; for (final Component component : container.getComponents()) { final Constraints constraints = layout.getConstraints(component); width = Spring.max(width, constraints.getWidth()); height = Spring.sum(height, constraints.getHeight()); if (previous == container) { layout.putConstraint(SpringLayout.NORTH, previous, initialY, SpringLayout.NORTH, component); } else { layout.putConstraint(SpringLayout.SOUTH, previous, yPad, SpringLayout.NORTH, component); }// www. ja v a 2 s . c om previous = component; } final Constraints containerConstraints = layout.getConstraints(container); containerConstraints.setConstraint(SpringLayout.SOUTH, height); containerConstraints.setConstraint(SpringLayout.EAST, width); } }