|
-
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks