home *** CD-ROM | disk | FTP | other *** search
- import java.applet.Applet;
- import java.awt.Container;
- import java.awt.Event;
- import java.awt.Image;
- import java.awt.LayoutManager;
- import java.awt.Panel;
-
- public class CoolMove extends Applet implements Runnable {
- ScrollCanvas scroller;
- Thread animatorThread;
- boolean frozen = false;
- int moveAdd = -2;
-
- public void init() {
- super.init();
- ((Container)this).setLayout((LayoutManager)null);
- ((Panel)this).addNotify();
- Image var1 = ((Applet)this).getImage(((Applet)this).getCodeBase(), ((Applet)this).getParameter("SRC"));
- String var2 = ((Applet)this).getParameter("MOVE");
- if (var2 != null) {
- try {
- this.moveAdd = -Integer.parseInt(var2);
- } catch (NumberFormatException var3) {
- }
- }
-
- this.scroller = new ScrollCanvas(var1);
- ((Container)this).add(this.scroller);
- }
-
- public String getAppletInfo() {
- return "ScrollApplet by Marcus Schiesser";
- }
-
- public void start() {
- if (!this.frozen) {
- if (this.animatorThread == null) {
- this.animatorThread = new Thread(this);
- }
-
- this.animatorThread.start();
- }
-
- }
-
- public void stop() {
- this.animatorThread = null;
- }
-
- public boolean mouseDown(Event var1, int var2, int var3) {
- if (this.frozen) {
- this.frozen = false;
- this.start();
- } else {
- this.frozen = true;
- this.stop();
- }
-
- return true;
- }
-
- public boolean handleEvent(Event var1) {
- return super.handleEvent(var1);
- }
-
- public void run() {
- Thread.currentThread().setPriority(1);
- long var1 = System.currentTimeMillis();
-
- while(Thread.currentThread() == this.animatorThread) {
- this.scroller.scrollImage(this.moveAdd);
- this.scroller.repaint();
-
- try {
- var1 += 50L;
- Thread.sleep(Math.max(0L, var1 - System.currentTimeMillis()));
- } catch (InterruptedException var3) {
- return;
- }
- }
-
- }
- }
-