2025-03-05 21:25:34 +01:00
|
|
|
import java.awt.*;
|
|
|
|
import java.awt.event.*;
|
|
|
|
import javax.swing.*;
|
2025-03-05 21:21:31 +01:00
|
|
|
|
2025-03-05 21:25:34 +01:00
|
|
|
public class Attente extends JComponent implements WindowListener {
|
|
|
|
private boolean enArrierePlan = false;
|
2025-03-05 21:21:31 +01:00
|
|
|
|
2025-03-05 21:25:34 +01:00
|
|
|
public Attente() {
|
|
|
|
super();
|
|
|
|
}
|
2025-03-05 21:21:31 +01:00
|
|
|
|
2025-03-05 21:25:34 +01:00
|
|
|
@Override
|
|
|
|
protected void paintComponent(Graphics pinceau) {
|
|
|
|
Graphics secondPinceau = pinceau.create();
|
|
|
|
secondPinceau.setColor(this.getForeground());
|
2025-03-05 21:21:31 +01:00
|
|
|
|
2025-03-05 21:25:34 +01:00
|
|
|
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);
|
|
|
|
} else {
|
|
|
|
secondPinceau.setColor(Color.GREEN);
|
|
|
|
secondPinceau.fillRect(0, 0, getWidth(), getHeight());
|
|
|
|
secondPinceau.setColor(Color.MAGENTA);
|
|
|
|
secondPinceau.fillOval(100, 100, 100, 100);
|
|
|
|
}
|
|
|
|
}
|
2025-03-05 21:21:31 +01:00
|
|
|
|
2025-03-05 21:25:34 +01:00
|
|
|
@Override
|
|
|
|
public void windowDeactivated(WindowEvent evenement) {
|
|
|
|
System.out.println("Fenêtre mise en arrière-plan !");
|
|
|
|
enArrierePlan = true;
|
|
|
|
repaint();
|
|
|
|
}
|
2025-03-05 21:21:31 +01:00
|
|
|
|
2025-03-05 21:25:34 +01:00
|
|
|
@Override
|
|
|
|
public void windowActivated(WindowEvent e) {
|
|
|
|
System.out.println("Fenêtre active !");
|
|
|
|
enArrierePlan = false;
|
|
|
|
repaint();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override public void windowOpened(WindowEvent e) {}
|
|
|
|
@Override public void windowClosing(WindowEvent e) {}
|
|
|
|
@Override public void windowClosed(WindowEvent e) {}
|
|
|
|
@Override public void windowIconified(WindowEvent e) {}
|
|
|
|
@Override public void windowDeiconified(WindowEvent e) {}
|
|
|
|
}
|