Mouse Cursor

Hi all…

I am having problem trying to change my cursor’s image, for example when the person do a mouse pressed the icon for the mouse will change but it just refuse to change… any recommended sites or examples which I can use to solve this problem?

Codes will help to… :stuck_out_tongue:

Cheers!

Show us your code.

i believe its also dependant on your hadrware in that your hadrware needs to support different cursors. But most modern hardware should.

FInally tell us what your OS and pltform is.

Try this code. Of course you will have to replace methodThatReturnsBufferedImage() with something that’s actually part of your code, but other than that you’re good to go.


BufferedImage cursor=methodThatReturnsBufferedImage();
Cursor myCursor= Toolkit.getDefaultToolkit().createCustomCursor(cursor,new Point(0,0),"");
setCursor(myCursor);

You might want to store a bunch of them as an array to call them up easily.
Oh, and one more thing, there’s a glitch on the Mac where the cursor goes back to normal after your window loses and recieves focus again. Add a FocusListener and when the window regains focus then reset the cursor to your custom cursor.
Happy Coding!

Also, be careful which component you change the cursor for.

Thanks… I am using Win XP on a Acer to do my programming.

Thanks… it was the component problem…

Cheers!