import java.awt.*; import java.awt.event.*; import javax.swing.*; public class MyLayout extends JFrame { public MyLayout() { Container pane = getContentPane(); pane.setLayout (new BorderLayout (5, 5)); JPanel centerPane = new JPanel (); centerPane.setLayout (new GridLayout (0,2)); centerPane.add (new JButton ("Center1")); centerPane.add (new JButton ("Center2")); centerPane.add (new JButton ("Center3")); centerPane.add (new JButton ("Center4")); pane.add (centerPane, BorderLayout.CENTER); JPanel bottomPane = new JPanel (); bottomPane.setLayout (new BoxLayout (bottomPane, BoxLayout.X_AXIS)); bottomPane.add (new JButton ("Bottom1")); bottomPane.add (Box.createHorizontalGlue ()); bottomPane.add (new JButton ("Bottom2")); bottomPane.add (Box.createRigidArea (new Dimension (10,10))); bottomPane.add (new JButton ("Bottom3")); pane.add (bottomPane, BorderLayout.SOUTH); } public static void main(String args[]) { MyLayout frame = new MyLayout(); frame.setTitle("BorderLayout"); frame.pack(); frame.setVisible(true); } }