HTML CODING:
<html><body>
<applet code="myapp" width="300" height="300">
</applet>
</body>
</html>
JAVA CODING:
import java.awt.*;import java.applet.*;
public class myapp extends Applet implements Runnable {
String msg="PRO JAVA TRICKS. ";
char ch;
boolean stopFlag= true;
Thread t= null;
public void start()
{
t = new Thread(this);
stopFlag=false;
t.start();
}
public void run(){
for(;;){
try{
repaint();
Thread.sleep(250);
ch = msg.charAt(0);
msg = msg.substring(1,msg.length());
msg = msg + ch;
if(stopFlag)
break;
}catch(InterruptedException e) {}
}
}
public void stop(){
stopFlag=true;
t = null;
}
public void paint(Graphics g)
{
Font f= new Font("forte",Font.ITALIC,36);
g.setFont(f);
g.drawString(msg,220,350);
Color c2 = new Color(52,137,137);
setBackground(c2);
}
}
This comment has been removed by the author.
ReplyDelete