• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Change Image Of Mouse Cursor

 
merwin pinto
Ranch Hand
Posts: 39
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Is it possible to change the default cursor to an image? .... ...something like we have in MS Paint.
the Cursor class has shapes like the HourGlass etc. which is good
but can the cursor be associated to an image?
I am trying to write an Whiteboard Application and when the user would click on the pencil button , i want the pencil image to appear instead of the cursor .... How can i achive this using the Cursor class?
 
Joe Coughlin
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We have used :

Toolkit toolkit = getToolkit();
// Wherever your image is:
Image cursorImage = toolkit.getImage(dataDirectory + File.separator
+ "icons" + File.separator + "circleCursor.gif");

Point cursorHotSpot = new Point(15, 15);

Cursor lightPenCursor = toolkit.createCustomCursor(cursorImage,
cursorHotSpot, "lightPenCursor");

setCursor(lightPenCursor); //Within a JPanel

I hope this helps.
 
merwin pinto
Ranch Hand
Posts: 39
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot Joe. That information really helped.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic