import java.awt.*; import java.lang.*; import java.io.*; import java.net.*; import java.util.*; public class rwho extends java.applet.Applet implements Runnable{ private URL theUrl; private URLConnection www; private DataInputStream in; private Font font; private Thread theScroll; private int speed; private Graphics offGraphics; private Dimension offDimension; private Image offImage; private String toPrint; private int x2 = 0,y = 1,total; private boolean start = true; public void init() { String urlString = getParameter("url"); String temp = getParameter("speed"); speed = Integer.valueOf(temp).intValue(); temp = getParameter("size"); font = new Font("Helvetica",Font.PLAIN,Integer.valueOf(temp).intValue()); try { theUrl = new URL(urlString); } catch (MalformedURLException e) { System.out.println("Malformed url: "+e); } toPrint = do_rwho(theUrl); } public void start() { theScroll = new Thread(this); theScroll.start(); } public void stop() { theScroll.stop(); } public void run() { while (true) { try {Thread.currentThread().sleep(speed);} catch (InterruptedException e){} repaint(); } } public void paint(Graphics g) { if (offImage != null) { g.drawImage(offImage, 0, 0, null); } } public void update(Graphics g) { Dimension d = size(); // Create the offscreen graphics context if ((offGraphics == null) || (d.width != offDimension.width) || (d.height != offDimension.height)) { offDimension = d; offImage = createImage(d.width, d.height); offGraphics = offImage.getGraphics(); } // Erase the previous image offGraphics.setColor(Color.white); offGraphics.fillRect(0, 0, d.width, d.height); offGraphics.setColor(Color.black); // Paint the frame into the image paintFrame(offGraphics); // Paint the image onto the screen g.drawImage(offImage, 0, 0, null); } /* * Paint a frame of animation. */ public void paintFrame(Graphics g) { Dimension d = size(); g.setFont(font); FontMetrics fm = g.getFontMetrics(); total = d.height + fm.getHeight(); StringTokenizer token = new StringTokenizer(toPrint,","); y--; if (start) { y=total; x2=0; start = false; } if (y<=0) { x2++; y=total-d.height; if (x2>=token.countTokens()) { x2=0; toPrint = do_rwho(theUrl); token = new StringTokenizer(toPrint,","); y=total; } } String trashMe = ""; for (int i=0;i