DEV/DEV2.1/TP5:MiseEnPageEtDessin/Damier.java

20 lines
535 B
Java
Raw Normal View History

2023-03-20 17:57:20 +01:00
import javax.swing.*;
import java.awt.*;
public class Damier{
public static void main(String[] args) {
JFrame fenetre = new JFrame();
fenetre.setSize(400, 400);
fenetre.setLocation(0, 0);
GridLayout grille = new GridLayout(5,5);
fenetre.setLayout(grille);
fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
for (int i=0; i < 25; ++i){
JPanel panel = new JPanel();
panel.setBackground(i%2 == 0 ? Color.WHITE : Color.CYAN);
fenetre.add(panel);
} fenetre.setVisible(true);
}
}