This commit is contained in:
Emmanuel Srivastava
2025-03-05 21:32:35 +01:00
parent db705f93a8
commit 3d1afc128c
2 changed files with 12 additions and 10 deletions

View File

@@ -6,6 +6,7 @@ public class Fond extends JPanel implements ActionListener {
private JButton Cyan, Magenta, Jaune;
public Fond() {
super();
this.setLayout(null);
this.Cyan = new JButton("Cyan");
@@ -26,7 +27,7 @@ public class Fond extends JPanel implements ActionListener {
}
@Override
public void actionPerformed(ActionEvent evenement) {
protected void actionPerformed(ActionEvent evenement) {
if (evenement.getSource() == this.Cyan) {
this.setBackground(Color.CYAN);
} else if (evenement.getSource() == this.Magenta) {

View File

@@ -15,13 +15,14 @@ public class Attente extends JComponent implements WindowListener {
secondPinceau.setColor(this.getForeground());
if (enArrierePlan) {
secondPinceau.setColor(Color.BLACK);
int[] xHaut = {100, 150, 200};
int[] yHaut = {100, 150, 100};
int[] xBas = {100, 150, 200};
int[] yBas = {250, 200, 250};
secondPinceau.fillPolygon(xHaut, yHaut, 3);
secondPinceau.fillPolygon(xBas, yBas, 3);
int col = 5;
int ligne = 5;
int caseWidth = getWidth() / col;
int caseHeight = getHeight() / ligne;
secondPinceau.setColor(Color.CYAN);
int[] xPoints = {0,caseWidth * col, 0, caseWidth * col};
int[] yPoints = {0,0,caseHeight * ligne, caseHeight * ligne};
secondPinceau.fillPolygon(xPoints, yPoints, 4);
} else {
secondPinceau.setColor(Color.GREEN);
secondPinceau.fillRect(0, 0, getWidth(), getHeight());
@@ -32,14 +33,14 @@ public class Attente extends JComponent implements WindowListener {
@Override
public void windowDeactivated(WindowEvent evenement) {
System.out.println("Fenêtre mise en arrière-plan !");
System.out.println("Fenêtre mise en arrière-plan");
enArrierePlan = true;
repaint();
}
@Override
public void windowActivated(WindowEvent e) {
System.out.println("Fenêtre active !");
System.out.println("Fenêtre active");
enArrierePlan = false;
repaint();
}