34 lines
720 B
Java
34 lines
720 B
Java
|
import javax.swing.*;
|
||
|
import java.awt.*;
|
||
|
|
||
|
public class Damier {
|
||
|
public static void main(String[] args) {
|
||
|
|
||
|
int taille = Integer.parseInt(args[0]);
|
||
|
JFrame fenetre = new JFrame();
|
||
|
fenetre.setSize(500, 500);
|
||
|
fenetre.setLocation(0, 0);
|
||
|
GridLayout main = new GridLayout(taille,taille);
|
||
|
fenetre.setLayout(main);
|
||
|
|
||
|
for (int i = 0;i<taille;i++)
|
||
|
{
|
||
|
for (int j = 0;j<taille;j++)
|
||
|
{
|
||
|
JPanel temp = new JPanel();
|
||
|
if ((i+j)%2==0)
|
||
|
{
|
||
|
temp.setBackground(Color.CYAN);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
temp.setBackground(Color.WHITE);
|
||
|
}
|
||
|
fenetre.add(temp);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||
|
fenetre.setVisible(true);
|
||
|
}
|
||
|
}
|