exemple d'applet Java pour raffraîchir l'image ( solution ancien jdk)

import java.applet.*;
import java.awt.*;

public class
reaf extends Applet implements Runnable {
   int
I ; // compteur boucle
   int
X ; // position X
   int
Y = 50 ; // position Y
   int
sens=1 ; // sens    
   Thread
t ;

   public void start()   {  // Mise en place d'un thread
         if (
t == null) {
             
t = new Thread(this);
             
t .start();
        }
   }

   public void stop() {    // Suppression du thread
             if (
t != null) {
                 
t .stop();
                 
t = null;
             }
   }

   public void paint(Graphics g) {
       
g.drawString ("bouge pas !",X,Y);
    }

   public void run() {   // Affichage permanent
       while (true)   {
             for (
I=0 ;I<=300 ;I++)   {
                    if (
X ==100)
                        
sens = -1 ;
                    if (
X == 0)
                        
sens = 1 ;
                   
X=X+1*sens ;
                   repaint();
                   try     {
                       Thread.sleep(
50);
                   }
                   catch (InterruptedException ie)  {
                   }
    }    }
}
}


installes donc JAVA !
titre.gif (1044 octets)

dsdem.gif (1088 octets)