/** BorderPanel.java -- With this layout we explicitly put something in one of * 5 places: north, east, south, west and center. */ import java.awt.*; import javax.swing.*; public class BorderPanel extends JPanel { public BorderPanel() { setLayout(new BorderLayout()); setBackground(Color.green); JLabel caption = new JLabel("feed the birds", SwingConstants.CENTER); JLabel picture = new JLabel(new ImageIcon("lagoon.jpg")); JButton b1 = new JButton("Button 1"); JButton b2 = new JButton("Button 2"); JButton b3 = new JButton("Button 3"); add(caption, BorderLayout.NORTH); add(picture, BorderLayout.SOUTH); add(b1, BorderLayout.WEST); add(b2, BorderLayout.CENTER); add(b3, BorderLayout.EAST); } }