Controle machine
This commit is contained in:
BIN
DEV2.1/controle_machine_1/Declinaisons/Fenetre.class
Normal file
BIN
DEV2.1/controle_machine_1/Declinaisons/Fenetre.class
Normal file
Binary file not shown.
24
DEV2.1/controle_machine_1/Declinaisons/Fenetre.java
Normal file
24
DEV2.1/controle_machine_1/Declinaisons/Fenetre.java
Normal file
@@ -0,0 +1,24 @@
|
||||
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]);
|
||||
}
|
||||
}
|
||||
}
|
BIN
DEV2.1/controle_machine_1/Declinaisons/Main.class
Normal file
BIN
DEV2.1/controle_machine_1/Declinaisons/Main.class
Normal file
Binary file not shown.
6
DEV2.1/controle_machine_1/Declinaisons/Main.java
Normal file
6
DEV2.1/controle_machine_1/Declinaisons/Main.java
Normal file
@@ -0,0 +1,6 @@
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
Fenetre fenetre = new Fenetre();
|
||||
fenetre.setVisible(true);
|
||||
}
|
||||
}
|
BIN
DEV2.1/controle_machine_1/Declinaisons/Triangle.class
Normal file
BIN
DEV2.1/controle_machine_1/Declinaisons/Triangle.class
Normal file
Binary file not shown.
27
DEV2.1/controle_machine_1/Declinaisons/Triangle.java
Normal file
27
DEV2.1/controle_machine_1/Declinaisons/Triangle.java
Normal file
@@ -0,0 +1,27 @@
|
||||
import java.awt.*;
|
||||
import javax.swing.*;
|
||||
|
||||
public class Triangle extends JComponent {
|
||||
|
||||
private Color couleur;
|
||||
|
||||
public Triangle(Color couleur) {
|
||||
super();
|
||||
this.couleur = couleur;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paintComponent(Graphics pinceau) {
|
||||
Graphics secondPinceau = pinceau.create();
|
||||
|
||||
if (this.isOpaque()) {
|
||||
secondPinceau.setColor(this.getBackground());
|
||||
secondPinceau.fillRect(0, 0, this.getWidth(), this.getHeight());
|
||||
}
|
||||
|
||||
secondPinceau.setColor(this.couleur);
|
||||
int[] coordTriangleX = {0, this.getWidth(), this.getWidth()/2};
|
||||
int[] coordTriangleY = {this.getHeight()/3, this.getHeight()/4*3, this.getHeight()};
|
||||
secondPinceau.fillPolygon(coordTriangleX, coordTriangleY, 3);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user