LoadImage2
|
import java.applet.*; import java.awt.*; public class loadimage2 extends Applet { public Image logo; public void init() { logo=getImage(getDocumentBase(),"logo.jpg"); //The following line creates a tracker. MediaTracker tracker=new MediaTracker(this); //We give the image we want to track the //identification number 0. tracker.addImage(logo,0); //With the waitForAll() method the image can //be loaded. It will throw an InterrupterException //if something happens. try { tracker.waitForAll(); } catch(InterruptedException e) { System.out.println("Something happened while reading image..."); } } public void paint(Graphics g) { //Draw the image with drawImage(). g.drawImage(logo,0,0,this); } } |
Copyright © 1999 Scandinavia Online AB and Mandomartis Software Company |