Java examples for Swing:Layout Manager
add To Flow Layout
//package com.java2s; import java.awt.FlowLayout; import javax.swing.JComponent; import javax.swing.JPanel; public class Main { public static JPanel addToFlowLayout(JComponent comp, int flowLayoutAlignment) { JPanel panel = new JPanel(new FlowLayout(flowLayoutAlignment)); panel.add(comp);//from w w w .j a v a2 s.com return panel; } }