From 3d1afc128cde074ceb8d6262e46cd5f4168fd534 Mon Sep 17 00:00:00 2001 From: Emmanuel Srivastava Date: Wed, 5 Mar 2025 21:32:35 +0100 Subject: [PATCH] update --- DEV.2.1/TP/TP8-Evenements/1.Fond/Fond.java | 3 ++- .../TP/TP8-Evenements/2.Attente/Attente.java | 19 ++++++++++--------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/DEV.2.1/TP/TP8-Evenements/1.Fond/Fond.java b/DEV.2.1/TP/TP8-Evenements/1.Fond/Fond.java index 736a299..38a68eb 100644 --- a/DEV.2.1/TP/TP8-Evenements/1.Fond/Fond.java +++ b/DEV.2.1/TP/TP8-Evenements/1.Fond/Fond.java @@ -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) { diff --git a/DEV.2.1/TP/TP8-Evenements/2.Attente/Attente.java b/DEV.2.1/TP/TP8-Evenements/2.Attente/Attente.java index 1e36187..3c8fbd8 100644 --- a/DEV.2.1/TP/TP8-Evenements/2.Attente/Attente.java +++ b/DEV.2.1/TP/TP8-Evenements/2.Attente/Attente.java @@ -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(); }