Sunday, January 12, 2014

Another Simple Banner Program in Java

//--------------------------------------------------
//run this prg by appletviwer SimpleBanner2.java applet based
//--------------------------------------------------
//--------------------------------------------------

/*
<applet code="SimpleBanner2" width=300 height=350>
</applet>
*/
//---------------------------------------------------
import java.awt.*;
import java.applet.*;

public class SimpleBanner2 extends Applet implements Runnable{

String msg="Vidhya Sagar Womens College";
int y =20;
Thread t = null;

public void init(){
setBackground(Color.cyan);
setForeground(Color.red);
}

public void start(){
t = new Thread(this);
t.start();

}

public void run(){
for(;;){
try{
repaint();
Thread.sleep(250);
if(y <=100)
y = y +1;
else
y = 20;

  }catch(InterruptedException e){}

 }
}


public void paint(Graphics g){
g.drawString(msg,150,y);
}
}


Post a Comment