home *** CD-ROM | disk | FTP | other *** search
- import java.applet.Applet;
- import java.awt.Color;
- import java.awt.Component;
- import java.awt.Dimension;
- import java.awt.Event;
- import java.awt.Graphics;
- import java.awt.Image;
- import java.net.MalformedURLException;
- import java.net.URL;
-
- public class JavaQuote extends Applet implements Runnable {
- private Dimension size;
- private Image offImage;
- private Graphics offG;
- private ParamParser param;
- private Color bgcolor;
- private Thread animate;
- private long delay;
- private String link;
- private String target;
- private TextScript script;
-
- public void init() {
- this.size = ((Component)this).size();
- this.param = new ParamParser(this);
- this.bgcolor = this.param.parseColor("bgcolor", Color.white);
- ((Component)this).setBackground(this.bgcolor);
- this.delay = (long)this.param.parseInt("delay", 100);
- this.link = this.param.parseString("link", (String)null);
- this.target = this.param.parseString("target", "_self");
- this.offImage = ((Component)this).createImage(this.size.width, this.size.height);
- this.offG = this.offImage.getGraphics();
- this.script = new TextScript(this.offG, this.param, this.size);
- this.script.init();
- }
-
- public void start() {
- if (this.animate == null || !this.animate.isAlive()) {
- this.animate = new Thread(this);
- }
-
- this.animate.start();
- this.script.start();
- }
-
- public void run() {
- while(Thread.currentThread() == this.animate) {
- try {
- this.script.update();
- ((Component)this).repaint();
- Thread.sleep(this.delay);
- } catch (InterruptedException var2) {
- ((Throwable)var2).printStackTrace();
- }
- }
-
- }
-
- public void stop() {
- if (this.animate != null && this.animate.isAlive()) {
- this.script.stop();
- this.animate.stop();
- }
-
- }
-
- public void destroy() {
- this.animate = null;
- }
-
- public void update(Graphics var1) {
- this.script.paint(this.offG);
- this.paint(var1);
- }
-
- public void paint(Graphics var1) {
- var1.drawImage(this.offImage, 0, 0, this);
- }
-
- public boolean mouseDown(Event var1, int var2, int var3) {
- if (this.link != null) {
- try {
- URL var4 = new URL(((Applet)this).getDocumentBase(), this.link);
- ((Applet)this).getAppletContext().showDocument(var4, this.target);
- if (this.target.equals("_self")) {
- this.stop();
- }
- } catch (MalformedURLException var5) {
- ((Throwable)var5).printStackTrace();
- }
- }
-
- return true;
- }
-
- public boolean mouseEnter(Event var1, int var2, int var3) {
- if (this.link != null) {
- ((Applet)this).showStatus(this.link);
- }
-
- return true;
- }
-
- public boolean mouseExit(Event var1, int var2, int var3) {
- if (this.link != null) {
- ((Applet)this).showStatus("");
- }
-
- return true;
- }
- }
-