Here you can find the source of createHorizontalBoxLayout(Component... components)
public static JPanel createHorizontalBoxLayout(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 javax.swing.*; public class Main { public static JPanel createHorizontalBoxLayout(Component... components) { JPanel ret = new JPanel(); BoxLayout layout = new BoxLayout(ret, BoxLayout.X_AXIS); ret.setLayout(layout);//from www.j a v a2s .c o m for (Component component : components) { ret.add(component); } ret.setAlignmentX(Component.LEFT_ALIGNMENT); return ret; } }