Java Swing BoxLayout createPanelBoxLayout(Component... components)

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

Description

create Panel Box Layout

License

Open Source License

Declaration

static public JPanel createPanelBoxLayout(Component... components) 

Method Source Code

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

Related

  1. createBoxPanel(int axis)
  2. createBoxPanel(int orientation)
  3. createHorizontalBox(int[] ratios, Component... comps)
  4. createHorizontalBoxLayout(Component... components)
  5. createNorthPanel(JComponent p)
  6. createPanelWithBoxLayout()
  7. createTitledPanel(JComponent component, String title)
  8. createTopAndCenter(JComponent top, JComponent center)
  9. createVertBox(Component... comps)