import java.applet.Applet; import java.awt.Event; import java.awt.Graphics; import java.awt.Image; import java.net.URL; import java.net.MalformedURLException; public class CursorApplet extends Applet { private int mouse_x, mouse_y; // The position of the mouse private boolean Follow; // Do we want to follow the mouse? private Image CursorImage; public void init() { mouse_x = 125; mouse_y = 125; Follow = true; resize(600,600); String CursorFile = getParameter("CURSORFILE"); try { URL me = getCodeBase(); URL CursorURL = new URL(me,CursorFile); CursorImage = getImage(CursorURL); } catch (MalformedURLException e) { CursorImage = createImage(0,0); } } // End init() public void paint(Graphics g) { g.drawRect(0,0,599,599); g.drawImage(CursorImage,mouse_x,mouse_y,this); } // End paint public boolean mouseMove(Event evt, int x, int y) { if (Follow) { mouse_x = x; // Update our local mouse information mouse_y = y; repaint(); // Redraw the graphics window } return true; } // End mouseMove public boolean mouseDown(Event evt, int x, int y) { if (Follow) Follow = false; else Follow = true; return true; } // End MouseDown } // End class CursorApplet