Java Applet Program to Display Rolling Banner Using repaint( ) Method of an Applet

Write a Java applet program to display rolling banner using repaint( ) method of an applet.



Source Code
import java.awt.*;
import java.applet.*;
public class Banner extends Applet implements Runnable
{
	String msg = "Welcome to Java Applet";
	Thread t = null;
	Font f;
	
	public void init()
	{
		setBackground(Color.pink);
		setForeground(Color.blue);
		f = new Font("Times New Roman",Font.BOLD,20);
		setFont(f);
	}
	public void start() {
		t = new Thread(this);
		t.start();
	}
	public void run()
	{
		char ch;
		
		while(true)
		{
			repaint();
			ch = msg.charAt(0);
			msg = msg.substring(1,msg.length());
			msg = msg + ch;
				
			try
			{
				Thread.sleep(1000);				
			}
			catch(InterruptedException ie){
				System.out.println(ie);
			}
		}
	}
	public void stop()
	{
		t = null;
	}
	public void paint(Graphics g)
	{
		g.drawString(msg,50,30);
	}
}
/*	<applet code=Banner.class width=300 height=300>
 	</applet>	*/
Output