You should make a check to the Image whether is has been loaded or not. When you clikc the reload, it will not load the image again, because it has been loaded all.<br><br>The code is as follows, hope it will help you<br><br>import java.awt.*;<br>import java.applet.*;<br>import java.awt.image.ImageObserver;<br><br><br>public class Myown extends Applet implements ImageObserver<br>{<br><br> Image picture;<br> boolean ImageLoaded=false;<br> public void init()<br> {<br><br><b> picture=getImage(getCodeBase(),"summer.jpg");</b> if(picture != null)<br> {<br> Image offScreenImage = createImage(getSize().width, getSize().height);<br> Graphics offScreenGC = offScreenImage.getGraphics();<br> offScreenGC.drawImage(picture, 0, 0, this);<br> offScreenGC.finalize();<br><b> if(checkImage(offScreenImage,this)==ALLBITS)<br> {<br> ImageLoaded = true;<br> }<br> else<br> ImageLoaded = false;</b> }<br> else<br> System.out.println("NULL source");<br> }<br><br> public void paint(Graphics g)<br> {<br><br> if(ImageLoaded)<br> {<br> g.drawImage(picture,0,0,this);<br> showStatus("Done");<br> }<br> else<br> showStatus("Loading image");<br><br> g.dispose();<br> }<br> public boolean imageUpdate(Image img,int infoflags,int x,int y,int w,int h)<br> {<br> if(infoflags==ALLBITS)<br> {<br><br> ImageLoaded=true;<br> repaint();<br> return false;<br> }<br><br> else<br> return true;<br> }<br>}<br><br><br> |