home *** CD-ROM | disk | FTP | other *** search
- import java.applet.Applet;
- import java.applet.AudioClip;
- import java.awt.Color;
- import java.awt.Component;
- import java.awt.Event;
- import java.awt.Graphics;
- import java.awt.Image;
- import java.net.MalformedURLException;
- import java.net.URL;
-
- public class dynimg extends Applet implements Runnable {
- AudioClip sndclicked;
- AudioClip sndactive;
- Color bgColor = ((Component)this).getBackground();
- Image imginact;
- Image imgact;
- Image imgclicked;
- Image imgcurrent;
- String href;
- String target;
- Thread running;
-
- public void init() {
- String var1 = ((Applet)this).getParameter("bgcolor");
- if (var1 != null) {
- this.bgColor = this.convColor(var1);
- ((Component)this).setBackground(this.bgColor);
- }
-
- var1 = ((Applet)this).getParameter("url");
- if (var1 != null) {
- this.href = var1;
- }
-
- var1 = ((Applet)this).getParameter("target");
- if (var1 != null) {
- this.target = var1;
- }
-
- var1 = ((Applet)this).getParameter("inactive_image");
- if (var1 != null) {
- this.imginact = ((Applet)this).getImage(((Applet)this).getCodeBase(), var1);
- }
-
- var1 = ((Applet)this).getParameter("active_image");
- if (var1 != null) {
- this.imgact = ((Applet)this).getImage(((Applet)this).getCodeBase(), var1);
- }
-
- var1 = ((Applet)this).getParameter("clicked_image");
- if (var1 != null) {
- this.imgclicked = ((Applet)this).getImage(((Applet)this).getCodeBase(), var1);
- }
-
- var1 = ((Applet)this).getParameter("clicked_sound");
- if (var1 != null) {
- this.sndclicked = ((Applet)this).getAudioClip(((Applet)this).getCodeBase(), var1);
- }
-
- var1 = ((Applet)this).getParameter("active_sound");
- if (var1 != null) {
- this.sndactive = ((Applet)this).getAudioClip(((Applet)this).getCodeBase(), var1);
- }
-
- }
-
- public void start() {
- if (this.running == null) {
- this.running = new Thread(this);
- this.running.start();
- }
-
- }
-
- public void stop() {
- if (this.running != null) {
- this.running.stop();
- this.running = null;
- }
-
- }
-
- public void run() {
- this.imgcurrent = this.imginact;
- ((Component)this).repaint();
- ((Applet)this).getAppletContext().showStatus("Dynamic Image, Copyright (c) 1996 Nick Heinle");
-
- try {
- Thread.sleep(2000L);
- } catch (InterruptedException var1) {
- }
-
- ((Applet)this).getAppletContext().showStatus("");
- }
-
- public boolean mouseDown(Event var1, int var2, int var3) {
- if (this.imgclicked != null) {
- this.imgcurrent = this.imgclicked;
- ((Component)this).repaint();
- }
-
- if (this.sndclicked != null) {
- this.sndclicked.play();
- }
-
- return true;
- }
-
- public boolean mouseUp(Event var1, int var2, int var3) {
- if (this.imgact != null) {
- this.imgcurrent = this.imgact;
- ((Component)this).repaint();
- }
-
- if (this.href != null) {
- try {
- URL var4 = new URL(((Applet)this).getDocumentBase(), this.href);
- if (this.target != null) {
- ((Applet)this).getAppletContext().showDocument(var4, this.target);
- } else {
- ((Applet)this).getAppletContext().showDocument(var4);
- }
- } catch (MalformedURLException var5) {
- }
- }
-
- return true;
- }
-
- public boolean mouseEnter(Event var1, int var2, int var3) {
- if (this.imgact != null) {
- this.imgcurrent = this.imgact;
- ((Component)this).repaint();
- }
-
- if (this.sndactive != null) {
- this.sndactive.play();
- }
-
- if (this.href != null) {
- ((Applet)this).getAppletContext().showStatus(this.href);
- }
-
- return true;
- }
-
- public boolean mouseExit(Event var1, int var2, int var3) {
- if (this.imginact != null) {
- this.imgcurrent = this.imginact;
- ((Component)this).repaint();
- }
-
- if (this.href != null) {
- ((Applet)this).getAppletContext().showStatus("");
- }
-
- return true;
- }
-
- Color convColor(String var1) {
- int var2 = 0;
-
- try {
- if (var1.startsWith("#")) {
- var2 = Integer.parseInt(var1.substring(1), 16);
- } else if (var1.startsWith("0") && var1.length() > 1) {
- var2 = Integer.parseInt(var1.substring(1), 8);
- } else {
- var2 = Integer.parseInt(var1, 10);
- }
-
- return new Color(var2);
- } catch (NumberFormatException var3) {
- return null;
- }
- }
-
- public void paint(Graphics var1) {
- var1.drawImage(this.imgcurrent, 0, 0, this);
- }
-
- public void update(Graphics var1) {
- this.paint(var1);
- }
- }
-