Java Swing BoxLayout createVerticalBoxLayout(Component... components)

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

Description

create Vertical Box Layout

License

Open Source License

Declaration

public static JPanel createVerticalBoxLayout(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 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;
    }
}

Related

  1. createTitledPanel(JComponent component, String title)
  2. createTopAndCenter(JComponent top, JComponent center)
  3. createVertBox(Component... comps)
  4. createVerticalBox(Component... comps)
  5. createVerticalBox(Component... cs)
  6. execLoop(JComponent editor)
  7. hbox(Component[] components, int spacing)
  8. makeVerticalBoxPanel(int margin)
  9. newBox(String name, String... items)