Java Swing BoxLayout createHorizontalBoxLayout(Component... components)

Here you can find the source of createHorizontalBoxLayout(Component... components)

Description

create Horizontal Box Layout

License

Open Source License

Declaration

public static JPanel createHorizontalBoxLayout(Component... components) 

Method Source Code

//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;
    }
}

Related

  1. createBoxLayout(Container container, int axis, Component... components)
  2. createBoxLayoutPanel(boolean vertical)
  3. createBoxPanel(int axis)
  4. createBoxPanel(int orientation)
  5. createHorizontalBox(int[] ratios, Component... comps)
  6. createNorthPanel(JComponent p)
  7. createPanelBoxLayout(Component... components)
  8. createPanelWithBoxLayout()
  9. createTitledPanel(JComponent component, String title)