Forums Register Login

Change Image Of Mouse Cursor

+Pie Number of slices to send: Send
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?
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
Thanks a lot Joe. That information really helped.
Catch Ernie! Catch the egg! And catch this tiny ad too:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 4329 times.
Similar Threads
unable to change the cursor to string.
Change Curser
Change the cursor to pointer in the edit profile page.
Mouse Pointer Change
Change cursor type in DnD tree
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 04:34:55.