Here you can find the source of layoutCompactVertical(JComponent... list)
public static JComponent layoutCompactVertical(JComponent... list)
//package com.java2s; /***//from ww w . j ava 2 s.c o m * Copyright (C) 2010 Johan Henriksson * This code is under the Endrov / BSD license. See www.endrov.net * for the full text and how to cite. */ import java.awt.BorderLayout; import javax.swing.*; public class Main { public static JComponent layoutCompactVertical(JComponent... list) { JComponent last = list[list.length - 1]; for (int i = list.length - 2; i >= 0; i--) { JPanel p = new JPanel(new BorderLayout()); p.add(list[i], BorderLayout.NORTH); p.add(last, BorderLayout.SOUTH); last = p; } return last; /* JPanel p=new JPanel(new BorderLayout()); p.add(left,BorderLayout.WEST); p.add(right,BorderLayout.EAST); return p;*/ } }