import java.awt.*; import java.applet.*; /** */ public class RectDessinApplet extends Applet { public RectDessin monRect; public void init() { int x1, x2, y1, y2; Color maCouleur = new Color(255, 0, 0); // Il faut gérer l'exception possible try {x1=Integer.parseInt(this.getParameter("x1"));} catch (Exception e){x1=0;} try {y1=Integer.parseInt(this.getParameter("y1"));} catch (Exception e){y1=0;} try {x2=Integer.parseInt(this.getParameter("x2"));} catch (Exception e){x2=0;} try {y2=Integer.parseInt(this.getParameter("y2"));} catch (Exception e){y2=0;} this.monRect = new RectDessin(x1, y1, x2, y2, maCouleur); } public void paint(java.awt.Graphics g) { g.drawString("Coords Pt1 = " + monRect.x1 + " " + monRect.y1, 200, 40); g.drawString("Coords Pt2 = " + monRect.x2 + " " + monRect.y2, 200, 60); g.drawString("Perimetre = " + monRect.perimetre() + " pixels", 200, 80); g.drawString("Surface = " + monRect.surface() + " pixels^2", 200, 100); g.setColor(monRect.getColor()); monRect.dessin(g); monRect.deplace(20, 20); monRect.dessin(g); } }