-
Ticker Tape
The following code is missing something or has an error of some kind.
It produces an applet window, then stops with the following message
Exception: TickerTape
Start: applet not initialized
Please advise what is needed to make this applet work.
Thanks.
import java.awt.*;
import java.applet.*;
public class TickerTape extends Canvas implements Runnable
{
public String msg = new String("Thank you for visiting today");
public int count = 300;
Thread thread = null;
public TickerTape()
{
setBackground(Color.white);
start();
}
public void paint(Graphics g)
{
g.drawString( msg, count, 10 );
}
public void init()
{
//
}
public void start()
{
if ( thread == null )
{
thread = new Thread(this);
thread.start();
}
}
public void stop()
{
if ( thread != null )
{
thread.stop();
thread = null;
}
}
public void run()
{
while( thread != null )
{
repaint();
if(count < -400)
count = 300;
else
count--;
try
{
thread.sleep(50);
}
catch(InterruptedException e)
{
}
} // end of while
} // end of method run
} // end of class