import java.awt.*;
import javax.swing.*;

public class GridTest3 extends JFrame {
    JButton[] buttons = new JButton[10];
    Container contentPane;
    public GridTest3() {
	super("GridTest3");
	contentPane = getContentPane();
        int row = 3;
	// by setting columns to 0, the layout will try to put the components in 3 rows 
	contentPane.setLayout(new GridLayout(row, 0));
	for(int i = 0; i < buttons.length; i++) {
	    buttons[i] = new JButton(Integer.toString(i));
	    contentPane.add(buttons[i]);
	 }
    }
    
   public static void main(String[] args) {
        GridTest3 f = new GridTest3();
	f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	f.setSize(250,250);
	f.setVisible(true);
    }
}
