Home
JAVA APPLET
Creating Moving Banner
Here is an example to create a moving banner
import java.awt.*; import java.applet.Applet; public class banner1 extends Applet implements Runnable { String abc; Thread t=null; boolean ash; final Font f=new Font("Arial",Font.BOLD,20); public void init() { abc=getParameter("txt"); setBackground(Color.black); setForeground(Color.red); } public void start() { t=new Thread(this); ash=false; t.start(); } public void run() { char ch; for(;;) { try { repaint(); Thread.sleep(150); ch=abc.charAt(0); abc=abc.substring(1,abc.length()); abc=abc+ch; if(ash) break; } catch(InterruptedException e) {} } } public void stop() { ash=true; t=null; } public void paint(Graphics g) { g.setFont(f); g.drawString(abc,0,20); showStatus(abc); } }
Previous