/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package OSTP; /** * * @author SatCH */ import javax.swing.*; import java.awt.*; import java.applet.*; public class OSTP extends Applet implements Runnable { //Declare a Thread object Thread count; int x ; int y; Thread count2; // initialise applet public void init() { x = 380; y = 420; setBackground(Color.black); this.setSize(780, 440); // this.add(Go); // init thread count = new Thread(this); count2 = new Thread(this); //start the thread count.start(); } //Thread code , overrides run method of Runnable public void run() { boolean t; t=true; while(t) { try { // delay count.sleep(5); y=y-1; // tester la limite transversal if (y != 0); else t=false; if (x!= 750 && x!=0); else t=false; repaint(); } catch(Exception e) {} //do nothing } } // paint method public void paint(Graphics g){ g.setColor(Color.red); g.fillOval(x,y, 20,20); } }