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); Color tab[] = {blanc,cyan}; int l = Integer.parseInt(args[0]); JFrame fenetre = new JFrame(); fenetre.setSize(500, 300); fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); GridLayout gestionnaire = new GridLayout(l, l); fenetre.setLayout(gestionnaire); JTextArea block = new JTextArea(); for (int i=0; i<(l*l); i++){ block.setBackground(tab[i%2]); fenetre.add(block); } fenetre.setVisible(true); } }