import java.awt.Container; import javax.swing.JButton; import javax.swing.JFrame; public class Prova02 extends JFrame{ Prova02(){ setSize(500, 500); Container ctn = getContentPane(); ctn.setLayout(null); for (int x = 0; x <= 400; x += 31) { for (int y = 0; y <= 400; y += 31) { JButton btnok = new JButton(); btnok.setBounds(x, y, 30, 30); ctn.add(btnok); } } this.setVisible(true); } public static void main(String[] args) { Prova02 p = new Prova02(); } }