// banner //first step in animation
/*
init() // initialization
start() // create a thread and start it running
stop() // stop the thread
run() // contains the actual code that controls the applet.
destroy() // shutdown activities
paint() // called each time applet output must be re-drwan
repaint() // call repaint when the contents of the window change
update() // aviod situation of repainted
*/
import java.awt.*;
import java.applet.*;
public class app7 extends Applet implements Runnable
{
String msg=" Power of Java ";
Thread t=null;
int state;
boolean flag;
//set colors and initialize thread
public void init()
{
setBackground(Color.red);
setForeground(Color.white);
}
// start thread
public void start()
{
t=new Thread(this);
flag=false;
t.start();
}
// Entry point for the thread that runs the banner
public void run()
{
char ch;
// display banner
while(!flag)
{
try
{
repaint();
Thread.sleep(500);
ch=msg.charAt(0);
msg=msg.substring(1,msg.length());
msg+=ch;
if(flag)
break;
}
catch(InterruptedException e)
{
}
}
}
// pause the banner
public void stop()
{
flag=true;
t=null;
}
// display the banner
public void paint (Graphics g)
{
g.drawString(msg,50,30);
// to show the status of the
showStatus ("This is status bar ");
}
}
Output

Output in Applet