Here you can find the source of createVerticalBoxLayout(Component... components)
public static JPanel createVerticalBoxLayout(Component... components)
//package com.java2s; /******************************************************************************* * Copyright (c) 2014 Open Door Logistics (www.opendoorlogistics.com) * All rights reserved. This program and the accompanying materials * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at http://www.gnu.org/licenses/lgpl.txt ******************************************************************************/ import java.awt.Component; import java.util.Collection; import javax.swing.*; public class Main { public static JPanel createVerticalBoxLayout(Collection<? extends Component> components) { return createVerticalBoxLayout(components.toArray(new Component[components.size()])); }/*from w w w . jav a2 s . com*/ public static JPanel createVerticalBoxLayout(Component... components) { JPanel topPanel = new JPanel(); topPanel.setLayout(new BoxLayout(topPanel, BoxLayout.Y_AXIS)); for (Component component : components) { topPanel.add(component); } topPanel.setAlignmentX(Component.LEFT_ALIGNMENT); return topPanel; } }