Java JPanel Create newJPanel(int layoutAxis, Component... components)

Here you can find the source of newJPanel(int layoutAxis, Component... components)

Description

new J Panel

License

Open Source License

Declaration

private static JPanel newJPanel(int layoutAxis, Component... components) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.awt.Component;

import java.awt.LayoutManager;

import javax.swing.BoxLayout;
import javax.swing.JPanel;

public class Main {
    private static JPanel newJPanel(int layoutAxis, Component... components) {
        JPanel retval = new JPanel();
        retval.setLayout(new BoxLayout(retval, layoutAxis));
        for (Component component : components)
            retval.add(component);//ww  w .  j av a  2s . co m
        return retval;
    }

    /**
     * Return new JPanel with specified LayoutManager, containing specified components
     * @param layoutManager layout manager to use
     * @param components components to place into panel
     * @return new JPanel with specified LayoutManager, containing specified components
     */
    public static JPanel newJPanel(LayoutManager layoutManager, Component... components) {
        JPanel retval = new JPanel();
        retval.setLayout(layoutManager);
        for (Component component : components)
            retval.add(component);
        return retval;
    }
}

Related

  1. createPaletteJPanel(String title)
  2. createStandardJPanel()
  3. createVerticalBoxJPanel(JComponent parent)
  4. initPanel(Color color)
  5. newJPanel(Component... c)
  6. setJPanelOpaque(JPanel p, boolean opaque)
  7. vbox(JPanel panel, List components)
  8. vgrid(JPanel panel, List components, int space)