//******************************************************************** // marquee.java //******************************************************************** import java.applet.*; import java.awt.Graphics; //******************************************************************** public class marquee extends Applet implements Runnable { int x = 0; int y = 0; int width = 0; Thread my_thread = null; //---------------------------------------------------------------- public void init() { x = size().width; y = size().height / 2; width = x; } //---------------------------------------------------------------- public void start() { my_thread = new Thread(this); my_thread.start(); } //---------------------------------------------------------------- public void run() { while(true) { repaint(); x -= 10; if(x < 0) x = width; try { Thread.sleep(100); // The previous statement produces a compiler // warning without a try/catch statement. } catch(InterruptedException e) { } } } //---------------------------------------------------------------- public void paint(Graphics g) { g.drawString("Hello, Java!", x, y); } }