import java.applet.*; import java.awt.*; import java.awt.event.*; import java.util.Vector; import java.net.URL; public class ImageApplet extends Applet implements Runnable, MouseListener { volatile Thread runner; Vector imageVector = new Vector(), urlVector = new Vector(); boolean scroll = false; int index = 1, yValue = 0; boolean drawn = false; Graphics g2; Image buf; int frameDelay = 20, stopDelay = 5000; public void init() { int i = 1; String param; while ((param = getParameter("image" + new Integer(i).toString())) != null) { Image image = getImage(getCodeBase(), param); imageVector.add(image); urlVector.add(null); ++i; } int j = 1; while (j < i) { param = getParameter("url" + new Integer(j).toString()); if (param == null) { ++j; continue; } URL url = null; try { url = new URL(param); } catch (Exception e) { ++j; continue; }; urlVector.set(j - 1, url); System.err.println(url.toString()); ++j; } buf = createImage(getWidth(), getHeight()); g2 = buf.getGraphics(); param = getParameter("framedelay"); if (param != null) { try { frameDelay = Integer.parseInt(param); } catch (Exception e) { frameDelay = 20; } } param = getParameter("stopdelay"); if (param != null) { try { stopDelay = Integer.parseInt(param); } catch (Exception e) { stopDelay = 5000; } } addMouseListener(this); } public void start() { runner = new Thread(this); runner.start(); } public void stop() { runner = null; } public void paint(Graphics g) { update(g); } public void update(Graphics g) { g2.fillRect(0, 0, getWidth(), getHeight()); if (drawn) g2.drawImage((Image) imageVector.elementAt(index), 0, 0, getWidth(), getHeight(), Color.white, this); else { g2.drawImage((Image) imageVector.elementAt(index), 0, 0, getWidth(), getHeight() - yValue, Color.white, this); int index2 = index + 1; if (index2 + 1 > imageVector.size()) index2 = 0; g2.drawImage((Image) imageVector.elementAt(index2), 0, getHeight() - yValue, getWidth(), yValue, Color.white, this); } g.drawImage(buf, 0, 0, getWidth(), getHeight(), Color.white, this); } public void run() { while(true) { while (!drawn) { try { Thread.sleep(frameDelay); } catch (Exception e) { ; } ++yValue; repaint(); if (yValue > getHeight()) { yValue = 0; drawn = true; } } index = (index + 1 < imageVector.size()) ? index + 1 : 0; try { Thread.sleep(stopDelay); } catch (Exception e) { ; } drawn = false; } } public void mouseClicked(MouseEvent e) { if (e.getY() < getHeight() - yValue) { if (urlVector.elementAt(index) != null) { getAppletContext().showDocument((URL) urlVector.elementAt(index)); System.err.println(urlVector.elementAt(index).toString()); System.err.println(index); } } else { int num = (index + 1 < imageVector.size()) ? index + 1 : 0; if (urlVector.elementAt(num) != null) { getAppletContext().showDocument((URL) urlVector.elementAt(num)); System.err.println(urlVector.elementAt(num).toString()); System.err.println(num); } } } public void mouseEntered(MouseEvent e) {} public void mouseExited(MouseEvent e) {} public void mousePressed(MouseEvent e) {} public void mouseReleased(MouseEvent e) {} }