27 lines
843 B
Java
27 lines
843 B
Java
|
import javax.swing.*;
|
||
|
import java.awt.*;
|
||
|
|
||
|
public class Damier {
|
||
|
public static void main(String[] args) {
|
||
|
JFrame fenetre = new JFrame();
|
||
|
fenetre.setSize(500,300);
|
||
|
fenetre.setMinimumSize(new Dimension(300, 200));
|
||
|
GridLayout gestionnaire = new GridLayout(Integer.parseInt(args[0]), Integer.parseInt(args[0]));
|
||
|
fenetre.setLayout(gestionnaire);
|
||
|
for(int i = 0; i < Integer.parseInt(args[0])*Integer.parseInt(args[0]) ; i++){
|
||
|
JPanel panneau = new JPanel();
|
||
|
if((i%2)==1)
|
||
|
{
|
||
|
panneau.setBackground(Color.white);
|
||
|
fenetre.add(panneau);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
panneau.setBackground(Color.cyan);
|
||
|
fenetre.add(panneau);
|
||
|
}
|
||
|
}
|
||
|
fenetre.setVisible(true);
|
||
|
}
|
||
|
}
|