Fin du TP Heritage
This commit is contained in:
@@ -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.
|
||||
|
||||
|
Reference in New Issue
Block a user