/** * MyMouse. Get an image of a mouse from the file * mighty_mouse.jpg that resides in this folder * @author rhyspj * @version 10xi08 * */ public class MyMouse1 extends JApplet { // Constants protected static final int SIZE = 400; // size of the applet // Instance variables protected Image micky; protected int mickyX, mickyY; protected MediaTracker mt; protected URL base; public void init() { setSize(SIZE,SIZE); micky = null; mt = new MediaTracker(this); try { base = getDocumentBase(); } catch(Exception e){} micky = getImage(base,"mighty_mouse.jpg"); mt.addImage(micky, 1); try { mt.waitForAll(); } catch(InterruptedException ie) {} mickyX = 100; mickyY = 100; } public void paint(Graphics g) { super.paint(g); g.setColor(Color.white); g.fillRect(0,0,getWidth(),getHeight()); g.drawImage(micky, mickyX, mickyY, this); } }