What this is:
This is the explaination (partly) of an old java applet I once wrote.
This is obsolete software it does not run anymore in modern browsers.
But anyways I will explain it here for educational and archive purposes
To run it you will need an old Java version that still supports the old awt 1.02 event handling system.
You then can try it to run with the appletviewer which is delivered with the Sun sdk (system development kit)
See https://www.sun.com (currently owned by Oracle)
(see google for it)
Disclaimer:
Offcourse everything at your risk no liability for me :-)
Freeware
1: import java.applet.Applet; 2: import java.awt.*; 3: import java.awt.image.*;These are the package equired to run the applet
5: public class Panorama extends Applet implements Runnable 6: {Defenition of this applet
7: public static final String REVISION_DATE="July 29 2001"; 8: 9: Thread runner; 10: MediaTracker tracker; 11: String marker="nhgube EWUZ"; //security 12: String marker2="ina qra Oretu"; //security 13: boolean created; 14: 15: Image picture; 16: int x,y,xAdd,width,height,delay; 17: boolean bounce; 18: 19: String loadString="Loading please wait"; 20: 21: boolean mouseDown=false,mouseDraged=false,mouseIn=false; 22: Point mouse=new Point(0,0); 23: int stop=1; 24: 25: Object frame; 26: 27: boolean sizeVertical; 28: Image offscreenI; 29: Graphics offscreenG; 30:These are all kinds of class variables.
31: public void init() 32: {This method is called when after an applet is loaded from the Internet.
33: super.init(); 34: System.out.println(getAppletInfo()); 35: while (marker!="nhgube EWUZ" || marker2!="ina qra Oretu"){} 36: 37: if (getParameter("load_string")!=null) loadString=getParameter("load_string"); 38: 39: if (getParameter("size_vertical")!=null && getParameter("size_vertical").equalsIgnoreCase("true")) 40: { 41: sizeVertical=true; 42: offscreenI=createImage(size().width,size().height); 43: offscreenG=offscreenI.getGraphics(); 44: }else sizeVertical=false; 45: 46: 47: //geting the frame of this applet 48: frame = this; 49: while (frame != null && !(frame instanceof Frame)) { 50: frame = ((Component) frame).getParent(); 51: } 52: 53: created=false;line 33 super.init()
57: public void start() 58: { 59: if (runner==null){ runner = new Thread(this);runner.start();} 60: }This method is called when the applet is shown in the browser html page.
62: public void stop() 63: { 64: if (runner!=null){runner.stop();runner=null;} 65: }This methode is called when the user leaves the html page
1: import java.applet.Applet; 2: import java.awt.*; 3: import java.awt.image.*; 4: 5: public class Panorama extends Applet implements Runnable 6: { 7: public static final String REVISION_DATE="July 29 2001"; 8: 9: Thread runner; 10: MediaTracker tracker; 11: String marker="nhgube EWUZ"; //security 12: String marker2="ina qra Oretu"; //security 13: boolean created; 14: 15: Image picture; 16: int x,y,xAdd,width,height,delay; 17: boolean bounce; 18: 19: String loadString="Loading please wait"; 20: 21: boolean mouseDown=false,mouseDraged=false,mouseIn=false; 22: Point mouse=new Point(0,0); 23: int stop=1; 24: 25: Object frame; 26: 27: boolean sizeVertical; 28: Image offscreenI; 29: Graphics offscreenG; 30: 31: public void init() 32: { 33: super.init(); 34: System.out.println(getAppletInfo()); 35: while (marker!="nhgube EWUZ" || marker2!="ina qra Oretu"){} 36: 37: if (getParameter("load_string")!=null) loadString=getParameter("load_string"); 38: 39: if (getParameter("size_vertical")!=null && getParameter("size_vertical").equalsIgnoreCase("true")) 40: { 41: sizeVertical=true; 42: offscreenI=createImage(size().width,size().height); 43: offscreenG=offscreenI.getGraphics(); 44: }else sizeVertical=false; 45: 46: 47: //geting the frame of this applet 48: frame = this; 49: while (frame != null && !(frame instanceof Frame)) { 50: frame = ((Component) frame).getParent(); 51: } 52: 53: created=false; 54: } 55: 56: 57: public void start() 58: { 59: if (runner==null){ runner = new Thread(this);runner.start();} 60: } 61: 62: public void stop() 63: { 64: if (runner!=null){runner.stop();runner=null;} 65: } 66: 67: private boolean create() 68: { 69: delay=50;String tempS=getParameter("delay"); 70: if (tempS!=null) delay=Integer.parseInt(tempS); 71: 72: xAdd=-1;tempS=getParameter("x_add"); 73: if (tempS!=null) xAdd=Integer.parseInt(tempS); 74: 75: bounce=false;tempS=getParameter("bounce"); 76: if (tempS!=null) if (tempS.toLowerCase().equals("true")) bounce=true; 77: 78: String filename=getParameter("picture"); 79: 80: if (filename!=null) 81: { 82: MediaTracker tracker; 83: picture=getImage(getCodeBase(),filename); 84: tracker=new MediaTracker(this); 85: tracker.addImage(picture,0); 86: try 87: { 88: tracker.waitForID(0); 89: }catch (InterruptedException e) 90: { 91: System.out.println("IO error loading images"); 92: } 93: width=picture.getWidth(this); 94: height=picture.getHeight(this); 95: } 96: 97: return true; 98: } 99: 100: public void run() 101: { 102: while (Thread.currentThread() == runner) 103: { 104: repaint(); 105: pause(delay); 106: if (created) 107: { 108: if (!mouseDown) 109: { 110: x+=(stop*xAdd); 111: if (!bounce && (x<-width || x>=width)) x=0; 112: if (bounce && (x>=0 || x+width<=size().width)) 113: { 114: xAdd*=-1;x+=2*xAdd; 115: } 116: } 117: } else { repaint(200);created=create();} 118: } 119: } 120: 121: public boolean handleEvent(Event evt) 122: { 123: if (!created) return true; 124: switch (evt.id) 125: { 126: case Event.MOUSE_ENTER: 127: ((Frame)frame).setCursor(Frame.CROSSHAIR_CURSOR); 128: mouseIn=true; 129: return true; 130: case Event.MOUSE_EXIT: 131: ((Frame)frame).setCursor(Frame.DEFAULT_CURSOR); 132: mouseIn=false; 133: return true; 134: case Event.MOUSE_DOWN: 135: mouse.x=evt.x; 136: mouse.y=evt.y; 137: mouseDown=true; 138: mouseDraged=false; 139: return true; 140: case Event.MOUSE_UP: 141: if (evt.x>=size().width || evt.x<0 || evt.y>=size().height || evt.y<0) mouseIn=false; 142: if (mouseIn) ((Frame)frame).setCursor(Frame.CROSSHAIR_CURSOR); else ((Frame)frame).setCursor(Frame.DEFAULT_CURSOR); 143: mouseDown=false; 144: if (mouse.x==evt.x && mouse.y==evt.y && !mouseDraged) stop=0; else stop=1; 145: mouseDraged=false; 146: return true; 147: case Event.MOUSE_DRAG: 148: ((Frame)frame).setCursor(Frame.MOVE_CURSOR); 149: mouseDraged=true; 150: x+=(evt.x-mouse.x); 151: if (x<-width) x+=width; 152: if (x>=width) x-=width; 153: if ((evt.x<mouse.x && xAdd>0) || (evt.x>mouse.x && xAdd<0)) xAdd*=-1; 154: mouse.x=evt.x; 155: if (!sizeVertical) 156: { 157: y+=(evt.y-mouse.y); 158: if (y+height<=size().height) y=size().height-height; 159: if (y>0) y=0; 160: mouse.y=evt.y; 161: } 162: return true; 163: } 164: return true; 165: } 166: 167: public synchronized void update(Graphics g) 168: { 169: if (!created) 170: { 171: FontMetrics fm=getFontMetrics(g.getFont()); 172: int x=(int)((size().width-fm.stringWidth(loadString))/2),y=(size().height/2); 173: g.drawString(loadString,x,y); 174: } 175: if (picture!=null) 176: { 177: if (sizeVertical && picture.getHeight(this)!=size().height) 178: { 179: if (offscreenI!=null) 180: { 181: offscreenG.drawImage(picture,x,y,picture.getWidth(this),size().height, this ); 182: if (x<0) offscreenG.drawImage(picture,x+width,y,picture.getWidth(this),size().height,this); 183: if (x>0) offscreenG.drawImage(picture,x-width,y,picture.getWidth(this),size().height,this); 184: g.drawImage(offscreenI,0,0,this); 185: } 186: } else 187: { 188: g.drawImage(picture,x,y,this); 189: if (x<0) g.drawImage(picture,x+width,y,this); 190: if (x>0) g.drawImage(picture,x-width,y,this); 191: } 192: } 193: } 194: 195: public void paint(Graphics g) 196: { 197: update(g); 198: } 199: 200: public String getAppletInfo() 201: { 202: return " \nPanorama applet \n(c)1998 rvdb@comweb.nl \nhttp://www.comweb.nl/~rvdb\n"+REVISION_DATE; 203: } 204: 205: private void pause(int time) 206: { 207: if (time==0) return;//prevent a NullPointerException 208: try { Thread.sleep(time); } catch (InterruptedException e) {} 209: } 210: 211: }