Java Swing FlowLayout flowLayoutPanel(Component... components)

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

Description

flow Layout Panel

License

Open Source License

Declaration

public static JPanel flowLayoutPanel(Component... components) 

Method Source Code


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

import java.awt.Component;
import java.awt.FlowLayout;
import java.awt.LayoutManager;

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

public class Main {
    public static JPanel flowLayoutPanel(Component... components) {
        return newJPanel(new FlowLayout(), components);
    }/*from   ww w . j ava2 s  .c  o m*/

    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);
        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. addToFlowLayout(JComponent comp, int flowLayoutAlignment)
  2. createPanel(LayoutManager layout, Component... components)
  3. getFlowLayoutPanelLeftAligned(String title, Component component)
  4. layoutFlow(JComponent... list)
  5. wrapInPanel(final JComponent comp, final LayoutManager lm)