HI, I am making a game where i want clicking a radio button to change the cursor image. I have figured out how to create a custom cursor, and even change the current cursor to it. The problem im having is i want to change it while the program is running. I can say somthing like frame.addCursor(cursor) but that sets it permenantly. What i would like is to add it to a panel during run-time. If anyone knows how i would go abou this i would be gratefull.
Will this work as it is? Where can I put this, can i put this in the action performed of one of my panels? If this will work i thank you. But i cant try it out now but i will do so later.
Do u mean, upon selecting the radio button, the cursor must be changed to the customized one?
If it is so,
u add the snippet in the itemStateChanged() event....of the radiobutton
i.e.,
public void itemStateChanged(ItemEvent ie)
{
if(ie.getStateChange() == ItemEvent.SELECTED)
{
myPanel.setCursor(Toolkit.getDefaultToolkit().createCustomCursor(CursorImg, new Point
(0,0), "MyCursorImg"));
/
CursorImg - the image to display when the cursor is actived
new Point(0,0) - hotSpot
MyCursorImg - a localized description of the cursor, for Java Accessibility use /
Wow your the man! I already did what you said before and i havent tried your latest post yet, but it looks like it works. I already did alot of what you just said but somthing was slightly off so your code helps. I shall be rewarding you ;-)