import java.applet.Applet; import java.awt.*; /* <applet code="ex12_3.class" width=800 height=400 > <param name=text value="Welcome to NCR Examination!"> <param name=delay value="50"> </applet> */ public class ex12_3 extends Applet implements Runnable private String strText; private Thread thMover = null; private int nX, nY, nDelay; private Font fFont ; private int getParameter(String s1, int s2) String s = getParameter(s1) ; return (s != null) Integer•parseInt(s) : s2 ;
private String getParameter(String s1, String s2) String s = getParameter(s1) ; return (s != null) Integer.parseInt(s) : s2 ;
public void init() fFont = new Font("TimesRome", Font.BOLD, 40) ; setBackground(Color.black); strText = getParameter("text","Put your message in strText parm"); nX = getSize().height; nY = 80 ; nDelay = getParameter("delay", 80) ;
public void start() if(thMover == null) thMover = new Thread(this); thMover.start();
public void stop() thMover = null;
public void run() while(thMover != null) try Thread.sleep(nDelay);
catch(InterruptedException e) repaint ( );
public void paint(Graphics g) switch(nX % 6) case 0: g.setColor(Color. RED); break; case 1: g.setColor(Color. GREEN) break; case 2: g.setColor(Color. ORANGE; break; case 3: g.setColor(Color.GRAY); break; case 4: g.setColor(Color.YELLOW ; break; case 5: g.setColor(Color. BLUE);