import javax.swing.*; import java.awt.*; public class Damier { public static void main(String[] args){ JFrame frame = new JFrame("Damier"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); int xpan = Integer.parseInt(args[0]); int ypan; ypan = xpan; GridLayout gestionnaire = new GridLayout(xpan, ypan); frame.setLayout(gestionnaire); for(int i = 0; i < xpan*ypan; i++){ if(i % 2 == 0){ JPanel panneau = new JPanel(); panneau.setBackground(Color.WHITE); frame.add(panneau); }else{ JPanel panneau = new JPanel(); panneau.setBackground(Color.CYAN); frame.add(panneau); } } frame.setSize(500,500); frame.setLocation(500,250); frame.setVisible(true); } }