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) {
|
2025-03-05 21:32:35 +01:00
|
|
|
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);
|
2025-03-05 21:25:34 +01:00
|
|
|
} 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) {
|
2025-03-05 21:32:35 +01:00
|
|
|
System.out.println("Fenêtre mise en arrière-plan");
|
2025-03-05 21:25:34 +01:00
|
|
|
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) {
|
2025-03-05 21:32:35 +01:00
|
|
|
System.out.println("Fenêtre active");
|
2025-03-05 21:25:34 +01:00
|
|
|
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) {}
|
|
|
|
}
|