Παράδειγμα διάταξης GridLayout

java.awt.GridLayout

import javax.swing.JFrame;
import javax.swing.JButton;

import java.awt.GridLayout;

public class GridLayoutDemo {
    public static void main(String[] args) {
        JFrame jf = new JFrame("Hello, World!");
        
        jf.setBounds(0, 0, 800, 600);
        
        jf.setLayout(new GridLayout(3, 2));
        jf.add(new JButton("(1, 1)"));
        jf.add(new JButton("(1, 2)"));
        jf.add(new JButton("(2, 1)"));
        jf.add(new JButton("(2, 2)"));
        jf.add(new JButton("(3, 1)"));
        jf.add(new JButton("(3, 2)"));
        
        // Remember, the method show() is deprecated
        jf.setVisible(true);
    }
}