Java Swing FlowLayout createPanel(LayoutManager layout, Component... components)

Here you can find the source of createPanel(LayoutManager layout, Component... components)

Description

create Panel

License

Creative Commons License

Declaration

public static JPanel createPanel(LayoutManager layout, Component... components) 

Method Source Code


//package com.java2s;
/*//from w  ww.j a v  a 2 s  .c  om
 * CS 106A
 *
 * This instructor-provided file contains utility functions related to GUIs.
 *
 * Author : Marty Stepp
 * Version: Tue 2014/06/05
 * 
 * This file and its contents are copyright (C) Stanford University and Marty Stepp,
 * licensed under Creative Commons Attribution 2.5 License.  All rights reserved.
 */

import java.awt.*;

import javax.swing.*;

public class Main {
    public static JPanel createPanel(Component... components) {
        return createPanel(new FlowLayout(FlowLayout.CENTER), components);
    }

    public static JPanel createPanel(LayoutManager layout, Component... components) {
        JPanel panel = new JPanel(layout);
        for (Component comp : components) {
            panel.add(comp);
        }
        return panel;
    }
}

Related

  1. addToFlowLayout(JComponent comp, int flowLayoutAlignment)
  2. flowLayoutPanel(Component... components)
  3. getFlowLayoutPanelLeftAligned(String title, Component component)
  4. layoutFlow(JComponent... list)
  5. wrapInPanel(final JComponent comp, final LayoutManager lm)