import java.awt.*; import java.applet.Applet; import java.net.*; public class newatcde extends Applet implements Runnable{ // Setup and Initialize Global Variables String str[] = new String[5]; URL url[] = new URL[5]; int x[] = new int[5]; int speed, step, y; // speed (smaller = faster) int midy; int RGB[] = new int[3]; // Text RGB Values (array) Thread theThread; int j=1; public void init() { showStatus("Initializing..."); setForeground(new Color(0, 0, 0)); step = Integer.parseInt(getParameter("STEP")); speed = Integer.parseInt(getParameter("SPEED")); setFont(new Font("Courier", 0, 16)); FontMetrics fm = getFontMetrics(getFont()); int fontHeight = fm.getHeight(); for (int i=0; i<=4; i++) { String lname = "LINK" + (i+1); String uname = "URL" + (i+1); str[i] = getParameter(lname); try { url[i] = new URL(getParameter(uname)); } catch(MalformedURLException e) { return; } int msgWidth = fm.stringWidth(str[i]); x[i] = (size().width - msgWidth)/2; } // ends for } public void start() { theThread = new Thread(this); theThread.setPriority(theThread.MIN_PRIORITY); theThread.start(); } public void stop() { theThread = null; } public void run() { y=40; while (theThread != null) { y = y - step; if (y<=0) { y=40; j++; j = j % 5;} repaint(); // calls update() and then paint() if (y==22) { try { theThread.sleep (450); } catch (InterruptedException e) { } } try { theThread.sleep (speed); } catch (InterruptedException e) { } } // ends while thread !=null } // ends run() public void paint(Graphics g) { g.drawString(str[j], x[j], y); } } // end applet