// -------------------------------------------------- // AFFICHAGE D'IMAGE // -------------------------------------------------- import java.applet.*; import java.awt.*; public class AfficheImage extends Applet { Image im; MediaTracker mt = null; public boolean afficher = false; // Initialisation de l'applet public void init() { // Chargement de l'image im = getImage(getDocumentBase(), "smiley.gif"); // Attendre le chargement MediaTracker mt = new MediaTracker(this); mt.addImage(im, 0); try { mt.waitForAll(); } catch (Exception e) {} } // Affichage public void paint(Graphics g) { // Tracer un rectangle blanc (fond de l'applet) g.setColor(Color.white); g.fillRect(0, 0, size().width, size().height); // Affichage de l'image if (afficher) g.drawImage(im, 0, 0, this); } }