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