import javax.swing.*; import java.awt.*; import java.awt.event.*; public class Attente extends JComponent implements WindowListener { boolean plan = true; protected void paintComponent(Graphics g) { Graphics secondPinceau = g.create(); if (this.isOpaque()){ secondPinceau.setColor(this.getBackground()); secondPinceau.fillRect(0, 0, this.getWidth(), this.getHeight()); } secondPinceau.setColor(Color.GREEN); secondPinceau.fillRect(0, 0, this.getWidth(), this.getHeight()); if (plan == true){ secondPinceau.setColor(Color.RED); secondPinceau.fillOval(100, 90, 200, 200); } if (plan == false){ secondPinceau.setColor(Color.CYAN); Polygon poly1 = new Polygon(); poly1.addPoint(0,0); poly1.addPoint(this.getWidth(), 0); poly1.addPoint(this.getWidth()/2, this.getHeight()/2); secondPinceau.fillPolygon(poly1); Polygon poly2 = new Polygon(); poly2.addPoint(this.getWidth()/2, this.getHeight()/2); poly2.addPoint(0, this.getHeight()); poly2.addPoint(this.getWidth(), this.getHeight()); secondPinceau.fillPolygon(poly2); } } public void windowActivated(WindowEvent evenement) { plan = true; this.repaint(); } public void windowClosed(WindowEvent evenement){} public void windowClosing(WindowEvent evenement){} public void windowDeactivated(WindowEvent evenement) { plan = false; this.repaint(); } public void windowDeiconified(WindowEvent evenement){} public void windowIconified(WindowEvent evenement){} public void windowOpened(WindowEvent evenement){} public Attente(){ super(); } }