// 1fpsのアニメーション import java.applet.Applet; import java.awt.Graphics; public class Sample7 extends Applet implements Runnable // Runnableインターフェイスを実装 { int num, x = 200, y = 150; public void init() { Thread th = new Thread(this); th.start(); } public void run() { try { for(int i = 0; i < 20; i++ ) { num = i; x+=2; y+=1; repaint(); Thread.sleep(1000); } } catch(InterruptedException e){} } public void paint(Graphics g) { String str = num + "です"; g.drawString(str, 10, 10); g.fillOval(x, y, 10, 10); } } // end of Sample7.java