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 frame = new JFrame("Grid"); frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE ); frame.setSize(200, 200); frame.setLocation(200, 200); frame.setContentPane(new Grid()); frame.setVisible(true);