import java.awt.*;
import javax.swing.*;

public class GridTest2 extends JFrame {
    JButton[] buttons = new JButton[10];
    Container contentPane;
    public GridTest2() {
	super("GridTest2");
	contentPane = getContentPane();
	int row = 4, col = 3, hgap = 10, vgap = 5;
	contentPane.setLayout(new GridLayout(row, col, hgap, vgap));
	for(int i = 0; i < buttons.length; i++) {
	    buttons[i] = new JButton(Integer.toString(i));
	    contentPane.add(buttons[i]);
	 }
	 // add a new Button at the 4th position
	 // contentPane.add(new JButton("insert"), 4);
	 // remove the 1st button
	 // contentPane.remove(1);
    }
    
   public static void main(String[] args) {
        GridTest2 f = new GridTest2();
	f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	f.setSize(250,250);
	f.setVisible(true);
    }
}
