2024-01-29 17:28:51 +01:00
|
|
|
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]);
|
2024-03-18 13:54:22 +01:00
|
|
|
System.out.println(l);
|
2024-01-29 17:28:51 +01:00
|
|
|
JFrame fenetre = new JFrame();
|
2024-03-18 13:54:22 +01:00
|
|
|
fenetre.setSize(500, 500);
|
2024-01-29 17:28:51 +01:00
|
|
|
fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
|
|
|
|
GridLayout gestionnaire = new GridLayout(l, l);
|
|
|
|
|
fenetre.setLayout(gestionnaire);
|
|
|
|
|
for (int i=0; i<(l*l); i++){
|
2024-03-18 13:54:22 +01:00
|
|
|
JTextField block = new JTextField(" ");
|
|
|
|
|
if (i % 2 == 0)
|
|
|
|
|
block.setBackground(blanc);
|
|
|
|
|
else
|
|
|
|
|
block.setBackground(cyan);
|
|
|
|
|
fenetre.add(block);
|
2024-01-29 17:28:51 +01:00
|
|
|
}
|
|
|
|
|
fenetre.setVisible(true);
|
|
|
|
|
}
|
|
|
|
|
}
|