import java.awt.*;
import javax.swing.*;

public class GridTest4 extends JFrame {
    JButton[] buttons = new JButton[20];
    Container contentPane;
    public GridTest4() {
	super("GridTest4");
	contentPane = getContentPane();
        int col = 6;
	// by setting rows to 0, the layout will try to put the components in 6 columns 
	contentPane.setLayout(new GridLayout(0, col));
	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) {
        GridTest4 f = new GridTest4();
	f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	f.setSize(300,100);
	f.setVisible(true);
    }
}
