Java examples for Swing:FlowLayout
Put FlowLayout Panel inside a BorderLayout Panel
import java.awt.BorderLayout; import java.awt.FlowLayout; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.UIManager; import javax.swing.UIManager.LookAndFeelInfo; public class Main { public static void main(String[] arguments) { JFrame frame = new AlphabetBorder(); }// w w w . ja va 2 s.co m } class AlphabetBorder extends JFrame { JButton north = new JButton("North"); JButton south = new JButton("South"); JButton east = new JButton("East"); JButton west = new JButton("West"); AlphabetPanel alpha = new AlphabetPanel(); AlphabetBorder() { super("AlphabetBorder"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setSize(240, 300); setLayout(new BorderLayout()); add("North", north); add("South", south); add("East", east); add("West", west); add("Center", alpha); setVisible(true); } } class AlphabetPanel extends JPanel { JButton a = new JButton("A"); JButton b = new JButton("B"); JButton c = new JButton("C"); JButton d = new JButton("D"); JButton e = new JButton("E"); JButton f = new JButton("F"); AlphabetPanel() { FlowLayout lm = new FlowLayout(FlowLayout.LEFT); setLayout(lm); add(a); add(b); add(c); add(d); add(e); add(f); } }