import javax.swing.*; import java.awt.*; import java.awt.Color; public class Damier { public static void main(String[] args) { Color blanc = new Color(255,255,255); Color cyan = new Color(0,255,255); int l = Integer.parseInt(args[0]); System.out.println(l); JFrame fenetre = new JFrame(); fenetre.setSize(500, 500); fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); GridLayout gestionnaire = new GridLayout(l, l); fenetre.setLayout(gestionnaire); for (int i=0; i<(l*l); i++){ JTextField block = new JTextField(" "); if (i % 2 == 0) block.setBackground(blanc); else block.setBackground(cyan); fenetre.add(block); } fenetre.setVisible(true); } }