Search code examples
javacursorawtmouseevent

Mouse Jumping when I enter a label


A bit ago I posted a question on cursors here

and I was wondering how do I get the cursor to stop jumping so what I mean is then I enter the jlabel it shows it like normal and then after a couple of seconds it jumps to a different place now when I added the frame drag method I added this code to stop this form happening

this.setLocation(x - xMouse, y - yMouse);

But I was wondering how would add it into this method

 Toolkit toolkit = Toolkit.getDefaultToolkit();
    Image image = toolkit.getImage("C:\\Users\\christian\\Desktop\\Files\\The Iron Door Files\\TheIronDoorDev\\New Launcher\\src\\pkgnew\\launcher\\Images\\Mouse//Drag.png");
    Cursor c = toolkit.createCustomCursor(image ,new Point(FrameDrag.getX(),FrameDrag.getY()), "Cursor");
    FrameDrag.setCursor (c);
}                         

to stop this from happening as it can be annoying

Edit :

So now I have this code but when I run I get this

   int x = evt.getXOnScreen();
     int y = evt.getYOnScreen();
    Toolkit toolkit = Toolkit.getDefaultToolkit();
Image image = toolkit.getImage("C:\\Users\\christian\\Desktop\\Files\\The Iron Door Files\\TheIronDoorDev\\New Launcher\\src\\pkgnew\\launcher\\Images\\Mouse//Drag.png");
Cursor c = toolkit.createCustomCursor(image ,new Point(x - xMouse, y - yMouse), "Cursor");
FrameDrag.setCursor (c);




   run:
Exception in thread "AWT-EventQueue-0" java.lang.IndexOutOfBoundsException: invalid hotSpot
    at sun.awt.CustomCursor.<init>(CustomCursor.java:78)
    at sun.awt.windows.WCustomCursor.<init>(WCustomCursor.java:45)
    at sun.awt.windows.WToolkit.createCustomCursor(WToolkit.java:731)
    at pkgnew.launcher.LoadLauncher.FrameDragMouseEntered(LoadLauncher.java:219)
    at pkgnew.launcher.LoadLauncher.access$600(LoadLauncher.java:24)
    at pkgnew.launcher.LoadLauncher$5.mouseEntered(LoadLauncher.java:127)
    at java.awt.Component.processMouseEvent(Component.java:6514)
    at javax.swing.JComponent.processMouseEvent(JComponent.java:3320)
    at java.awt.Component.processEvent(Component.java:6270)
    at java.awt.Container.processEvent(Container.java:2229)
    at java.awt.Component.dispatchEventImpl(Component.java:4861)
    at java.awt.Container.dispatchEventImpl(Container.java:2287)
    at java.awt.Component.dispatchEvent(Component.java:4687)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832)
    at java.awt.LightweightDispatcher.trackMouseEnterExit(Container.java:4620)
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4474)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422)
    at java.awt.Container.dispatchEventImpl(Container.java:2273)
    at java.awt.Window.dispatchEventImpl(Window.java:2719)
    at java.awt.Component.dispatchEvent(Component.java:4687)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:735)
    at java.awt.EventQueue.access$200(EventQueue.java:103)
    at java.awt.EventQueue$3.run(EventQueue.java:694)
    at java.awt.EventQueue$3.run(EventQueue.java:692)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
    at java.awt.EventQueue$4.run(EventQueue.java:708)
    at java.awt.EventQueue$4.run(EventQueue.java:706)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:705)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)
Exception in thread "AWT-EventQueue-0" java.lang.IndexOutOfBoundsException: invalid hotSpot
    at sun.awt.CustomCursor.<init>(CustomCursor.java:78)
    at sun.awt.windows.WCustomCursor.<init>(WCustomCursor.java:45)
    at sun.awt.windows.WToolkit.createCustomCursor(WToolkit.java:731)
    at pkgnew.launcher.LoadLauncher.FrameDragMouseEntered(LoadLauncher.java:219)
    at pkgnew.launcher.LoadLauncher.access$600(LoadLauncher.java:24)
    at pkgnew.launcher.LoadLauncher$5.mouseEntered(LoadLauncher.java:127)
    at java.awt.Component.processMouseEvent(Component.java:6514)
    at javax.swing.JComponent.processMouseEvent(JComponent.java:3320)
    at java.awt.Component.processEvent(Component.java:6270)
    at java.awt.Container.processEvent(Container.java:2229)
    at java.awt.Component.dispatchEventImpl(Component.java:4861)
    at java.awt.Container.dispatchEventImpl(Container.java:2287)
    at java.awt.Component.dispatchEvent(Component.java:4687)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832)
    at java.awt.LightweightDispatcher.trackMouseEnterExit(Container.java:4620)
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4474)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422)
    at java.awt.Container.dispatchEventImpl(Container.java:2273)
    at java.awt.Window.dispatchEventImpl(Window.java:2719)
    at java.awt.Component.dispatchEvent(Component.java:4687)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:735)
    at java.awt.EventQueue.access$200(EventQueue.java:103)
    at java.awt.EventQueue$3.run(EventQueue.java:694)
    at java.awt.EventQueue$3.run(EventQueue.java:692)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
    at java.awt.EventQueue$4.run(EventQueue.java:708)
    at java.awt.EventQueue$4.run(EventQueue.java:706)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:705)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)
Exception in thread "AWT-EventQueue-0" java.lang.IndexOutOfBoundsException: invalid hotSpot
    at sun.awt.CustomCursor.<init>(CustomCursor.java:78)
    at sun.awt.windows.WCustomCursor.<init>(WCustomCursor.java:45)
    at sun.awt.windows.WToolkit.createCustomCursor(WToolkit.java:731)
    at pkgnew.launcher.LoadLauncher.FrameDragMouseEntered(LoadLauncher.java:219)
    at pkgnew.launcher.LoadLauncher.access$600(LoadLauncher.java:24)
    at pkgnew.launcher.LoadLauncher$5.mouseEntered(LoadLauncher.java:127)
    at java.awt.Component.processMouseEvent(Component.java:6514)
    at javax.swing.JComponent.processMouseEvent(JComponent.java:3320)
    at java.awt.Component.processEvent(Component.java:6270)
    at java.awt.Container.processEvent(Container.java:2229)
    at java.awt.Component.dispatchEventImpl(Component.java:4861)
    at java.awt.Container.dispatchEventImpl(Container.java:2287)
    at java.awt.Component.dispatchEvent(Component.java:4687)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832)
    at java.awt.LightweightDispatcher.trackMouseEnterExit(Container.java:4620)
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4474)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422)
    at java.awt.Container.dispatchEventImpl(Container.java:2273)
    at java.awt.Window.dispatchEventImpl(Window.java:2719)
    at java.awt.Component.dispatchEvent(Component.java:4687)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:735)
    at java.awt.EventQueue.access$200(EventQueue.java:103)
    at java.awt.EventQueue$3.run(EventQueue.java:694)
    at java.awt.EventQueue$3.run(EventQueue.java:692)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
    at java.awt.EventQueue$4.run(EventQueue.java:708)
    at java.awt.EventQueue$4.run(EventQueue.java:706)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:705)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)
Exception in thread "AWT-EventQueue-0" java.lang.IndexOutOfBoundsException: invalid hotSpot
    at sun.awt.CustomCursor.<init>(CustomCursor.java:78)
    at sun.awt.windows.WCustomCursor.<init>(WCustomCursor.java:45)
    at sun.awt.windows.WToolkit.createCustomCursor(WToolkit.java:731)
    at pkgnew.launcher.LoadLauncher.FrameDragMouseEntered(LoadLauncher.java:219)
    at pkgnew.launcher.LoadLauncher.access$600(LoadLauncher.java:24)
    at pkgnew.launcher.LoadLauncher$5.mouseEntered(LoadLauncher.java:127)
    at java.awt.Component.processMouseEvent(Component.java:6514)
    at javax.swing.JComponent.processMouseEvent(JComponent.java:3320)
    at java.awt.Component.processEvent(Component.java:6270)
    at java.awt.Container.processEvent(Container.java:2229)
    at java.awt.Component.dispatchEventImpl(Component.java:4861)
    at java.awt.Container.dispatchEventImpl(Container.java:2287)
    at java.awt.Component.dispatchEvent(Component.java:4687)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832)
    at java.awt.LightweightDispatcher.trackMouseEnterExit(Container.java:4620)
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4474)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422)
    at java.awt.Container.dispatchEventImpl(Container.java:2273)
    at java.awt.Window.dispatchEventImpl(Window.java:2719)
    at java.awt.Component.dispatchEvent(Component.java:4687)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:735)
    at java.awt.EventQueue.access$200(EventQueue.java:103)
    at java.awt.EventQueue$3.run(EventQueue.java:694)
    at java.awt.EventQueue$3.run(EventQueue.java:692)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
    at java.awt.EventQueue$4.run(EventQueue.java:708)
    at java.awt.EventQueue$4.run(EventQueue.java:706)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:705)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)
Exception in thread "AWT-EventQueue-0" java.lang.IndexOutOfBoundsException: invalid hotSpot
    at sun.awt.CustomCursor.<init>(CustomCursor.java:78)
    at sun.awt.windows.WCustomCursor.<init>(WCustomCursor.java:45)
    at sun.awt.windows.WToolkit.createCustomCursor(WToolkit.java:731)
    at pkgnew.launcher.LoadLauncher.FrameDragMouseEntered(LoadLauncher.java:219)
    at pkgnew.launcher.LoadLauncher.access$600(LoadLauncher.java:24)
    at pkgnew.launcher.LoadLauncher$5.mouseEntered(LoadLauncher.java:127)
    at java.awt.Component.processMouseEvent(Component.java:6514)
    at javax.swing.JComponent.processMouseEvent(JComponent.java:3320)
    at java.awt.Component.processEvent(Component.java:6270)
    at java.awt.Container.processEvent(Container.java:2229)
    at java.awt.Component.dispatchEventImpl(Component.java:4861)
    at java.awt.Container.dispatchEventImpl(Container.java:2287)
    at java.awt.Component.dispatchEvent(Component.java:4687)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832)
    at java.awt.LightweightDispatcher.trackMouseEnterExit(Container.java:4620)
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4474)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422)
    at java.awt.Container.dispatchEventImpl(Container.java:2273)
    at java.awt.Window.dispatchEventImpl(Window.java:2719)
    at java.awt.Component.dispatchEvent(Component.java:4687)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:735)
    at java.awt.EventQueue.access$200(EventQueue.java:103)
    at java.awt.EventQueue$3.run(EventQueue.java:694)
    at java.awt.EventQueue$3.run(EventQueue.java:692)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
    at java.awt.EventQueue$4.run(EventQueue.java:708)
    at java.awt.EventQueue$4.run(EventQueue.java:706)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:705)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)
Exception in thread "AWT-EventQueue-0" java.lang.IndexOutOfBoundsException: invalid hotSpot
    at sun.awt.CustomCursor.<init>(CustomCursor.java:78)
    at sun.awt.windows.WCustomCursor.<init>(WCustomCursor.java:45)
    at sun.awt.windows.WToolkit.createCustomCursor(WToolkit.java:731)
    at pkgnew.launcher.LoadLauncher.FrameDragMouseEntered(LoadLauncher.java:219)
    at pkgnew.launcher.LoadLauncher.access$600(LoadLauncher.java:24)
    at pkgnew.launcher.LoadLauncher$5.mouseEntered(LoadLauncher.java:127)
    at java.awt.Component.processMouseEvent(Component.java:6514)
    at javax.swing.JComponent.processMouseEvent(JComponent.java:3320)
    at java.awt.Component.processEvent(Component.java:6270)
    at java.awt.Container.processEvent(Container.java:2229)
    at java.awt.Component.dispatchEventImpl(Component.java:4861)
    at java.awt.Container.dispatchEventImpl(Container.java:2287)
    at java.awt.Component.dispatchEvent(Component.java:4687)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832)
    at java.awt.LightweightDispatcher.trackMouseEnterExit(Container.java:4620)
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4474)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422)
    at java.awt.Container.dispatchEventImpl(Container.java:2273)
    at java.awt.Window.dispatchEventImpl(Window.java:2719)
    at java.awt.Component.dispatchEvent(Component.java:4687)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:735)
    at java.awt.EventQueue.access$200(EventQueue.java:103)
    at java.awt.EventQueue$3.run(EventQueue.java:694)
    at java.awt.EventQueue$3.run(EventQueue.java:692)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
    at java.awt.EventQueue$4.run(EventQueue.java:708)
    at java.awt.EventQueue$4.run(EventQueue.java:706)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:705)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)
Exception in thread "AWT-EventQueue-0" java.lang.IndexOutOfBoundsException: invalid hotSpot
    at sun.awt.CustomCursor.<init>(CustomCursor.java:78)
    at sun.awt.windows.WCustomCursor.<init>(WCustomCursor.java:45)
    at sun.awt.windows.WToolkit.createCustomCursor(WToolkit.java:731)
    at pkgnew.launcher.LoadLauncher.FrameDragMouseEntered(LoadLauncher.java:219)
    at pkgnew.launcher.LoadLauncher.access$600(LoadLauncher.java:24)
    at pkgnew.launcher.LoadLauncher$5.mouseEntered(LoadLauncher.java:127)
    at java.awt.Component.processMouseEvent(Component.java:6514)
    at javax.swing.JComponent.processMouseEvent(JComponent.java:3320)
    at java.awt.Component.processEvent(Component.java:6270)
    at java.awt.Container.processEvent(Container.java:2229)
    at java.awt.Component.dispatchEventImpl(Component.java:4861)
    at java.awt.Container.dispatchEventImpl(Container.java:2287)
    at java.awt.Component.dispatchEvent(Component.java:4687)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832)
    at java.awt.LightweightDispatcher.trackMouseEnterExit(Container.java:4620)
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4474)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422)
    at java.awt.Container.dispatchEventImpl(Container.java:2273)
    at java.awt.Window.dispatchEventImpl(Window.java:2719)
    at java.awt.Component.dispatchEvent(Component.java:4687)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:735)
    at java.awt.EventQueue.access$200(EventQueue.java:103)
    at java.awt.EventQueue$3.run(EventQueue.java:694)
    at java.awt.EventQueue$3.run(EventQueue.java:692)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
    at java.awt.EventQueue$4.run(EventQueue.java:708)
    at java.awt.EventQueue$4.run(EventQueue.java:706)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:705)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)
Exception in thread "AWT-EventQueue-0" java.lang.IndexOutOfBoundsException: invalid hotSpot
    at sun.awt.CustomCursor.<init>(CustomCursor.java:78)
    at sun.awt.windows.WCustomCursor.<init>(WCustomCursor.java:45)
    at sun.awt.windows.WToolkit.createCustomCursor(WToolkit.java:731)
    at pkgnew.launcher.LoadLauncher.FrameDragMouseEntered(LoadLauncher.java:219)
    at pkgnew.launcher.LoadLauncher.access$600(LoadLauncher.java:24)
    at pkgnew.launcher.LoadLauncher$5.mouseEntered(LoadLauncher.java:127)
    at java.awt.Component.processMouseEvent(Component.java:6514)
    at javax.swing.JComponent.processMouseEvent(JComponent.java:3320)
    at java.awt.Component.processEvent(Component.java:6270)
    at java.awt.Container.processEvent(Container.java:2229)
    at java.awt.Component.dispatchEventImpl(Component.java:4861)
    at java.awt.Container.dispatchEventImpl(Container.java:2287)
    at java.awt.Component.dispatchEvent(Component.java:4687)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832)
    at java.awt.LightweightDispatcher.trackMouseEnterExit(Container.java:4620)
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4474)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422)
    at java.awt.Container.dispatchEventImpl(Container.java:2273)
    at java.awt.Window.dispatchEventImpl(Window.java:2719)
    at java.awt.Component.dispatchEvent(Component.java:4687)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:735)
    at java.awt.EventQueue.access$200(EventQueue.java:103)
    at java.awt.EventQueue$3.run(EventQueue.java:694)
    at java.awt.EventQueue$3.run(EventQueue.java:692)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
    at java.awt.EventQueue$4.run(EventQueue.java:708)
    at java.awt.EventQueue$4.run(EventQueue.java:706)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:705)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)
Exception in thread "AWT-EventQueue-0" java.lang.IndexOutOfBoundsException: invalid hotSpot
    at sun.awt.CustomCursor.<init>(CustomCursor.java:78)
    at sun.awt.windows.WCustomCursor.<init>(WCustomCursor.java:45)
    at sun.awt.windows.WToolkit.createCustomCursor(WToolkit.java:731)
    at pkgnew.launcher.LoadLauncher.FrameDragMouseEntered(LoadLauncher.java:219)
    at pkgnew.launcher.LoadLauncher.access$600(LoadLauncher.java:24)
    at pkgnew.launcher.LoadLauncher$5.mouseEntered(LoadLauncher.java:127)
    at java.awt.Component.processMouseEvent(Component.java:6514)
    at javax.swing.JComponent.processMouseEvent(JComponent.java:3320)
    at java.awt.Component.processEvent(Component.java:6270)
    at java.awt.Container.processEvent(Container.java:2229)
    at java.awt.Component.dispatchEventImpl(Component.java:4861)
    at java.awt.Container.dispatchEventImpl(Container.java:2287)
    at java.awt.Component.dispatchEvent(Component.java:4687)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832)
    at java.awt.LightweightDispatcher.trackMouseEnterExit(Container.java:4620)
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4474)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422)
    at java.awt.Container.dispatchEventImpl(Container.java:2273)
    at java.awt.Window.dispatchEventImpl(Window.java:2719)
    at java.awt.Component.dispatchEvent(Component.java:4687)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:735)
    at java.awt.EventQueue.access$200(EventQueue.java:103)
    at java.awt.EventQueue$3.run(EventQueue.java:694)
    at java.awt.EventQueue$3.run(EventQueue.java:692)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
    at java.awt.EventQueue$4.run(EventQueue.java:708)
    at java.awt.EventQueue$4.run(EventQueue.java:706)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:705)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)
Exception in thread "AWT-EventQueue-0" java.lang.IndexOutOfBoundsException: invalid hotSpot
    at sun.awt.CustomCursor.<init>(CustomCursor.java:78)
    at sun.awt.windows.WCustomCursor.<init>(WCustomCursor.java:45)
    at sun.awt.windows.WToolkit.createCustomCursor(WToolkit.java:731)
    at pkgnew.launcher.LoadLauncher.FrameDragMouseEntered(LoadLauncher.java:219)
    at pkgnew.launcher.LoadLauncher.access$600(LoadLauncher.java:24)
    at pkgnew.launcher.LoadLauncher$5.mouseEntered(LoadLauncher.java:127)
    at java.awt.Component.processMouseEvent(Component.java:6514)
    at javax.swing.JComponent.processMouseEvent(JComponent.java:3320)
    at java.awt.Component.processEvent(Component.java:6270)
    at java.awt.Container.processEvent(Container.java:2229)
    at java.awt.Component.dispatchEventImpl(Component.java:4861)
    at java.awt.Container.dispatchEventImpl(Container.java:2287)
    at java.awt.Component.dispatchEvent(Component.java:4687)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832)
    at java.awt.LightweightDispatcher.trackMouseEnterExit(Container.java:4620)
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4474)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422)
    at java.awt.Container.dispatchEventImpl(Container.java:2273)
    at java.awt.Window.dispatchEventImpl(Window.java:2719)
    at java.awt.Component.dispatchEvent(Component.java:4687)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:735)
    at java.awt.EventQueue.access$200(EventQueue.java:103)
    at java.awt.EventQueue$3.run(EventQueue.java:694)
    at java.awt.EventQueue$3.run(EventQueue.java:692)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)



BUILD STOPPED (total time: 11 seconds)

Edit 2 : Fixed that issue but still having the jump


Solution

  • The Point parameter to createCustomCursor is used to define the "hot spot" of the cursor

    That is, it describes the point in the cursor image where a mouse event will generate it's click point

    From the JavaDocs...

    public Cursor createCustomCursor(Image cursor,
        Point hotSpot,
        String name)
            throws IndexOutOfBoundsException,
            HeadlessException

    Creates a new custom cursor object. If the image to display is invalid, the cursor will be hidden (made completely transparent), and the hotspot will be set to (0, 0). Note that multi-frame images are invalid and may cause this method to hang.

    Parameters: cursor - the image to display when the cursor is actived
    hotSpot - the X and Y of the large cursor's hot spot; the hotSpot
    values must be less than the Dimension returned by getBestCursorSize
    name - a localized description of the cursor, for Java Accessibility use

    Updated

    enter image description here

    The "hotspot" defines the location within the cursor where the "click" point will be generated. In the first cursor, it's 12x5, in the second it's 10x5.

    So, the position of cursor on the screen will be relative to it's top, left corner (0x0 relative). When the user presses the mouse button, the system will add the "hotspot" offset to the current screen position and generate an appropriate mouse event.

    What I suspect is happening, is when you change the cursor, the system is trying to align the mouse's hotspot with the old cursors hotspot, which is causing it to jump about.