Could you tell me, Why it doesn't work. When I run it, mouse hides. but I want to change mouse cursor's icon.
import java.awt.Cursor;
import java.awt.Image;
import java.awt.Point;
import java.awt.Toolkit;
import java.awt.event.MouseEvent;
import javax.swing.JList;
import acm.program.GraphicsProgram;
public class test1 extends GraphicsProgram {
public Cursor stoneCursor;
public void run() {
Toolkit toolkit = Toolkit.getDefaultToolkit();
Image image = toolkit.getImage("cursor.gif");
Point hotspot = new Point(0, 0);
stoneCursor = toolkit.createCustomCursor(image, hotspot, "Stone");
getContentPane().setCursor(stoneCursor);
}
@Override
public void mouseDragged(MouseEvent e) {
}
}
Here is an example try this..
Standard Cursor Image:
User defined Image: