0

不久前,我在这里发布了一个关于游标的问题

我想知道如何让光标停止跳跃所以我的意思是然后我输入jlabel它像正常一样显示它然后几秒钟后它现在跳转到不同的地方当我添加框架拖动方法时我添加此代码以阻止此表单发生

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

但我想知道如何将它添加到这个方法中

 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);
}                         

阻止这种情况发生,因为它可能很烦人

编辑 :

所以现在我有这个代码但是当我运行时我得到了这个

   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)

编辑 2:修复了该问题,但仍有跳转

4

1 回答 1

3

Point参数 to用于定义光标的createCustomCursor“热点”

也就是说,它描述了光标图像中鼠标事件将产生它的点击点

从 JavaDocs...

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

创建一个新的自定义光标对象。如果要显示的图像无效,光标将被隐藏(完全透明),热点将设置为 (0, 0)。请注意,多帧图像无效,可能会导致此方法挂起。

参数: cursor - 激活光标时显示的图像
hotSpot - 大光标热点的 X 和 Y;热点
值必须小于 getBestCursorSize 返回的 Dimension
名称 - 游标的本地化描述,供 Java 可访问性使用

更新

在此处输入图像描述

“热点”定义了光标内将生成“点击”点的位置。在第一个光标中,它是 12x5,在第二个光标中是 10x5。

因此,光标在屏幕上的位置将相对于它的左上角(0x0 相对)。当用户按下鼠标按钮时,系统会将“热点”偏移量添加到当前屏幕位置,并生成相应的鼠标事件。

我怀疑正在发生的事情是,当您更改光标时,系统正在尝试将鼠标的热点与旧的光标热点对齐,这导致它跳来跳去。

于 2013-10-20T22:45:37.783 回答