satheesh
New Member
- Messages
- 883
- Reaction score
- 0
- Points
- 0
Code for java:
Save as MovingBanner.java and Compile and run it.
Demo:http://svprm.x10hosting.com/java/MovingBanner.html
Code:
/*
* MovingBanner.java
*
* Created on October 29, 2007, 7:16 PM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package satheesh;
import java.awt.*;
import java.applet.*;
/**
*
* @author Administrator
*/
public class MovingBanner extends Applet implements Runnable {
String msg;
Thread t=null;
int state;
boolean stopflag;
public void init()
{
setBackground(Color.BLACK);
setForeground(Color.WHITE);
}
public void start() {
msg=getParameter("msg");
t = new Thread(this);
stopflag=false;
t.start();
}
public void run(){
char ch;
for(;;){
try{
repaint();
Thread.sleep(250);
ch=msg.charAt(0);
msg=msg.substring(1,msg.length());
msg+=ch;
if(stopflag){
break;
}
}catch(InterruptedException e){
System.out.print("Error:"+e);
}
}
}
public void stop(){
stopflag=true;
t=null;
}
public void paint(Graphics g)
{
g.drawString(msg,10,30);
}
}
/*
<P>
<APPLET codebase="./" code="MovingBanner.class" width=150 height=50><param name="msg" value="-Free Hosting By x10hosting.com-">
</APPLET>
</P>
*/
Save as MovingBanner.java and Compile and run it.
Demo:http://svprm.x10hosting.com/java/MovingBanner.html