28 June 2006

Drawing Custom Cursor in Java Swing

Use ArtCursors software Trail version to draw an image and put that in say multimedia\test.gif in your Eclipse project folder.
Use the code:
Toolkit CursorTk = Toolkit.getDefaultToolkit();
CursorImage = CursorTk.getImage(".\\multimedia\\test.gif");
int Width = CursorImage.getWidth(null);
if (Width >= 0)
System.out.println("Image Loaded");
} else {
System.out.println("Image Loading Failed");

Cursor TunnelCursor = CursorTk.createCustomCursor(CursorImage,new Point(0,0),"cursor");

Object is a your Farme/Panel object.

I will post a complete code that does all these in a while....


No comments:

Post a Comment

Please leave a note about what you think about this write up. Thanks.