setLayout(new GridLayout(3, 2)); add(new JButton("One")); add(new JButton("Two")); add(new JButton("Three")); add(new JButton("Four")); add(new JButton("Five"));
JFrame f = new JFrame("Grid"); f.addWindowListener(new WindowAdapter( ) { public void windowClosing(WindowEvent e) { System.exit(0); } }); f.setSize(200, 200); f.setLocation(200, 200); f.setContentPane(new Grid( )); f.setVisible(true);