import java.awt.*;
import javax.swing.*;

public class BoxLayoutExample extends JFrame {

	public BoxLayoutExample() {
		super("BoxLayout example");

		JPanel left = new JPanel();
		left.setLayout(new BoxLayout(left, BoxLayout.Y_AXIS));
		left.add(new JLabel("1"));
		left.add(new JLabel("2"));
		left.add(new JLabel("3"));

		JPanel right = new JPanel();
		right.setLayout(new BoxLayout(right, BoxLayout.Y_AXIS));
		right.add(new JLabel("1"));
		right.add(new JLabel("2"));
		right.add(new JLabel("3"));

		Container cp = getContentPane();
		cp.setLayout(new BoxLayout(cp, BoxLayout.X_AXIS));
		cp.add(Box.createHorizontalStrut(10));
		cp.add(left);
		cp.add(Box.createHorizontalGlue());
		cp.add(right);
		cp.add(Box.createHorizontalStrut(10));
	}

	public static void main(String args[]) {
		BoxLayoutExample b = new BoxLayoutExample();
		b.pack();
		b.setVisible(true);
	}
}
