import java.awt.GridLayout; import javax.swing.JButton; import javax.swing.JFrame; public class MainWindow extends JFrame { JButton button1 = new JButton("gomb1"); JButton button2 = new JButton("gomb2"); JButton button3 = new JButton("gomb3"); JButton button4 = new JButton("gomb4"); JButton button5 = new JButton("gomb5"); JButton button6 = new JButton("gomb6"); JButton button7 = new JButton("gomb7"); public MainWindow() { this.setLayout(new GridLayout(4, 2)); this.add(button1); this.add(button2); this.add(button3); this.add(button4); this.add(button5); this.add(button6); this.add(button7); this.setTitle("GridLayout"); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.pack(); this.setVisible(true); } }