aspose file tools*
The moose likes Java in General and the fly likes Using Custom Cursors Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Using Custom Cursors" Watch "Using Custom Cursors" New topic
Author

Using Custom Cursors

Barry Andrews
Ranch Hand

Joined: Sep 05, 2000
Posts: 523

I have some animation on a JPanel, and I also have a custom cursor that I built like this:
Toolkit tk = Toolkit.getDefaultToolkit();
target = tk.getImage("target.jpg");
sights = new JButton();
sights.setCursor(tk.createCustomCursor(target,new Point(0,0),"cursor"));

Now my problem comes in when I try to add it to the JPanel. It does not show up at all. I just have the normal mouse cursor. If I add it to the Container before I add the JPanel, I only get the cursor and not the JPanel. If I add the cursor after I add the JPanel, I get only the JPanel. I need to have the animation
and the custom cursor on the same JPanel. If anyone can help me with this, I would greatly appreciate it. Thanks!!!

 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Using Custom Cursors
 
Similar Threads
well did as below but BUTTONS NOT Appear only the image plays continuesly, well
repaint() method? Something's fishy...
Trouble Aligning JButtons (And setting width)
Java Swing Custom Cursor ( Mac styled rotating dots busy cursor)
Using Custom Cursors