Fin du TP Heritage

This commit is contained in:
Simoes Lukas
2025-02-06 14:32:11 +01:00
parent 209f320a5a
commit dd0903e9fc
21 changed files with 304 additions and 20 deletions

View File

@@ -26,3 +26,46 @@ public class Test {
2.
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);
Color color_1 = Color.WHITE;
Color color_2 = Color.CYAN;
for (int j = 0; j < a; j++) {
Color temp = color_1;
color_1 = color_2;
color_2 = temp;
for(int i = 0; i < a; i++) {
JPanel panneau = new JPanel();
if (i%2 == 0) {
panneau.setBackground(color_1);
}
else {
panneau.setBackground(color_2);
}
fenetre.add(panneau);
}
}
fenetre.setVisible(true);
}
}
3.