import java.awt.*;
import javax.swing.*;

public class GridTest extends JFrame {
    JButton[] buttons = new JButton[5];
    JLabel[] labels = new JLabel[5];
    String[] strings = {"zero", "one", "two", "three", "four"};
    Container contentPane;
    public GridTest() {
        super("GridTest");
	contentPane = getContentPane();
	int row = 5;
	int col = 2;
	contentPane.setLayout(new GridLayout(row,col));
	// add labels and buttons
	// the components are added from left to right, top to bottom
	for(int i = 0; i < buttons.length; i++) {
	    // create labels and add to contentPane
	    labels[i] = new JLabel(strings[i], JLabel.CENTER);
	    contentPane.add(labels[i]);
	    // create buttons and add to contentPane
	    // Integer.toString(i) changes integer i to string
	    buttons[i] = new JButton(Integer.toString(i));
	    contentPane.add(buttons[i]);
	 }
    }
    
   public static void main(String[] args) {
        GridTest f = new GridTest();
	f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	f.setSize(100,200);
	f.setVisible(true);
    }
}

