Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Blink custom cursor

843806Aug 12 2008 — edited Aug 12 2008
Hi to all.

I'm having problems changing the look of the cursor of my app. Sometimes, when the user let the mouse pointer on certain areas of the principal panel, the cursor look must change for a custom look that I have created. The problem is that when I change the aspect of the system cursor, for my custom cursor, it start to blink sometimes, and it stays blinking when I move it on areas where the cursor have to have this custom look. I'm using a code like this.

All this is into a class that extends from JPane.
public void paintComponent(Graphics g) {
        
        Toolkit toolkit = Toolkit.getDefaultToolkit();
        Image image = toolkit.getImage("CrearTransiciones.gif");
        Point hotSpot = new Point(15, 15);
        Cursor cursor = toolkit.createCustomCursor(image, hotSpot, "CrearTransiciones");

        if (cursorIsOver().equals(ZoneOver.Zone1)) {
            setCursor(cursor);
        } else {
           if (cursorIsOver().equals(ZoneOver.Zone2)) {
               setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
           } else {
              if (cursorIsOver().equals(ZoneOver.Zone3)) {
                  setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR));
              }
           }
        }
}
I have also proved to set the hotSpot into the (0, 0) point, but I'm still having the same problem.

Someone knows what I have to do to avoid the annoying blinking?

Thanks for read.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 9 2008
Added on Aug 12 2008
1 comment
176 views