24 lines
756 B
Java
24 lines
756 B
Java
![]() |
import java.awt.*;
|
||
|
import javax.swing.*;
|
||
|
|
||
|
public class Fenetre extends JFrame {
|
||
|
public Fenetre() {
|
||
|
this.setSize(400, 400);
|
||
|
this.setLocation(100, 100);
|
||
|
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||
|
this.setLayout(new GridLayout(2, 2));
|
||
|
|
||
|
JPanel[] panneaux = new JPanel[4];
|
||
|
Color[] couleursFond = {Color.CYAN, Color.PINK, Color.MAGENTA, Color.YELLOW};
|
||
|
Color[] couleursTriangles = {Color.MAGENTA, Color.YELLOW, Color.CYAN, Color.BLUE};
|
||
|
|
||
|
for (int i = 0; i != 4; i++) {
|
||
|
panneaux[i] = new JPanel();
|
||
|
panneaux[i].setLayout(new BorderLayout());
|
||
|
panneaux[i].setOpaque(true);
|
||
|
panneaux[i].setBackground(couleursFond[i]);
|
||
|
panneaux[i].add(new Triangle(couleursTriangles[i]), BorderLayout.CENTER);
|
||
|
this.add(panneaux[i]);
|
||
|
}
|
||
|
}
|
||
|
}
|