/** GridPanel.java -- The grid layout lets you have a specific number of rows * and columns. */ import java.awt.*; import javax.swing.*; public class GridPanel extends JPanel { public GridPanel() { setLayout(new GridLayout(3,2)); // 3 rows and 2 columns setBackground(Color.green); JLabel caption = new JLabel("feed the birds"); 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"); // Components get added in order left-to-right, top-to-bottom. add(caption); add(picture); add(b1); add(b2); add(b3); } }