Java tutorial
//package com.java2s; import java.awt.Component; import java.util.Arrays; import javax.swing.JPanel; public class Main { /** * Places the given components in a JPanel with a FlowLayout. * @param components the components to add * @return a JPanel with a FlowLayout with the given components */ public static JPanel flowLayout(Component... components) { final JPanel result = new JPanel(); // FlowLayout is default Arrays.stream(components).forEach(result::add); return result; } }