// // Image Loading test // //import java.awt.Graphics; //import java.awt.Image; import java.awt.*; import java.lang.Math; public class LoadImg extends java.applet.Applet implements Runnable { Image Pic[] = new Image[1] ; boolean loop = true; Thread kicker = null; int px=0,py=0 ; int width =80 ; int height =60 ; int wait =60 ; int imgwidth =640 ; int imgheight=960 ; String fname="rottane.jpg" ; public void init() { Pic[0]=getImage(getCodeBase(), fname); } public void paint(Graphics g) { update(g); } public void update(Graphics g) { if(Pic[0]==null) { g.drawString("Error when loading picture", 0, 0); } g.drawImage(Pic[0],px,py, this); } public void start() { if(kicker == null) { kicker=new Thread(this); kicker.start(); } } public void stop() { if ( kicker != null ) { kicker.stop(); kicker = null; } } public void run() { while(loop) { repaint(); px-=width ; if( px<=-(imgwidth) ){ px=0 ; py-=height ; if( py<=-(imgheight) ){ py=0 ; } } try { Thread.sleep( 50 ); } catch (InterruptedException e){} } } }