import java.awt.*;
import java.awt.event.*;
import java.applet.*;
/*
<applet code=jitender width=400 height=400>
</applet>
*/
public class jitender extends Applet implements Runnable
{
Thread t=null;
boolean stopflag;
String msg,ch1;
public void init()
{
setBackground(Color.cyan);
setForeground(Color.red);
}
public void start()
{
msg="A simple jitender moving";
if(msg==null)
{
msg="message not found";
}
msg=" "+msg;
t=new Thread(this);
stopflag=false;
t.start();
}
public void run()
{
char ch;
String ch1;
char p1[]=msg.toCharArray();
for( ; ;)
{
try
{
repaint();
Thread.sleep(250);
ch=p1[p1.length-1];
for(int i=p1.length-1;i>0;i--)
{
p1[i]=p1[i-1];
}
p1[0]=ch;
ch1= String.valueOf(p1);
msg=ch1;
if(stopflag)
{
break;
}
}catch(InterruptedException e){}
}
}
public void stop()
{
stopflag=true;
t=null;
}
public void paint(Graphics g)
{
g.drawString(msg,50,30);
}
}
import java.awt.event.*;
import java.applet.*;
/*
<applet code=jitender width=400 height=400>
</applet>
*/
public class jitender extends Applet implements Runnable
{
Thread t=null;
boolean stopflag;
String msg,ch1;
public void init()
{
setBackground(Color.cyan);
setForeground(Color.red);
}
public void start()
{
msg="A simple jitender moving";
if(msg==null)
{
msg="message not found";
}
msg=" "+msg;
t=new Thread(this);
stopflag=false;
t.start();
}
public void run()
{
char ch;
String ch1;
char p1[]=msg.toCharArray();
for( ; ;)
{
try
{
repaint();
Thread.sleep(250);
ch=p1[p1.length-1];
for(int i=p1.length-1;i>0;i--)
{
p1[i]=p1[i-1];
}
p1[0]=ch;
ch1= String.valueOf(p1);
msg=ch1;
if(stopflag)
{
break;
}
}catch(InterruptedException e){}
}
}
public void stop()
{
stopflag=true;
t=null;
}
public void paint(Graphics g)
{
g.drawString(msg,50,30);
}
}
No comments:
Post a Comment