Full width home advertisement

HTML

Tech News

Ad

  1. package pkgApplet;
  2.  
  3. import java.applet.Applet;
  4. import java.awt.Graphics;
  5.  
  6. /**
  7.  *
  8.  * @author smit
  9.  */
  10. public class PR32 extends Applet implements Runnable {
  11.  
  12. Thread t;
  13. int x, y;
  14.  
  15. public void init() {
  16. t = new Thread(this);
  17. t.start();
  18. }
  19.  
  20. public void paint(Graphics g){
  21. x=(int) (Math.random()*1000);
  22. y=(int)(Math.random()*1000);
  23. g.fillOval(x, y, 50, 50);
  24. }
  25.  
  26. public void run() {
  27. try {
  28. while (true) {
  29. repaint();
  30. Thread.sleep(500);
  31. }
  32. } catch (InterruptedException x) {
  33. System.out.println(x);
  34. }
  35. }
  36. }

No comments:

Post a Comment

Bottom Ad [Post Page]