APL/APL2.1/TP3/Damier.java

27 lines
843 B
Java
Raw Normal View History

2022-02-07 16:15:08 +01:00
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);
}
}