Here you can find the source of createPanelBoxLayout(Component... components)
static public JPanel createPanelBoxLayout(Component... components)
//package com.java2s; /******************************************************************************* * Copyright (c) 2010 Costantino Cerbo./* ww w . ja v a 2 s. c o m*/ * All rights reserved. This program and the accompanying materials * are made available under the terms of the GNU Lesser Public License v2.1 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html * * Contributors: * Costantino Cerbo - initial API and implementation ******************************************************************************/ import java.awt.Component; import javax.swing.BoxLayout; import javax.swing.JPanel; public class Main { static public JPanel createPanelBoxLayout(int axis, Component... components) { JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, axis)); for (Component component : components) { panel.add(component); } return panel; } static public JPanel createPanelBoxLayout(Component... components) { int axis = BoxLayout.X_AXIS; return createPanelBoxLayout(axis, components); } }