2013-10-20 88 views
0

有點前,我貼在光標here鼠標跳躍,當我輸入標籤

,我想知道如何得到光標停止跳躍所以我的意思是,然後我進入它顯示了它的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:修正了一個問題,但仍有跳轉

回答

3

參數Point用於定義光標的「熱點」

也就是說,它描述光標圖像中的點鼠標事件將產生它的點擊點

從JavaDoc中......

公共光標createCustomCursor(圖像用光標,
       點熱點
       字符串名稱)
               拋出IndexOutOfBoundsException異常,
                HeadlessException的

創建一個新的自定義光標對象。如果要顯示的圖像無效,光標 將被隱藏(變爲完全透明),熱點將爲 設爲(0,0)。請注意,多幀圖像無效,可能會導致此方法掛起。

參數:cursor - 光標處於激活狀態時顯示的圖像
hotSpot - 大光標熱點的X和Y;熱點
值必須小於getBestCursorSize返回的尺寸
名字 - 光標的本地化描述,用於Java輔助 使用

更新

enter image description here

的「熱點」定義了光標內「點擊」點的位置。在第一個遊標中,它是12x5,第二個遊標是10x5。

因此,光標在屏幕上的位置將相對於它的頂部左角(相對於0x0)。當用戶按下鼠標按鈕時,系統會將「熱點」偏移量添加到當前屏幕位置並生成適當的鼠標事件。

我懷疑發生了什麼,當您更改光標時,系統正在嘗試將鼠標的熱點與舊的光標熱點對齊,這會導致它跳動。

+0

我仍然不明白如何使用它壽 –

+0

所以我需要做的相對熱點定義光標(其中爲0x0的頂部,左上角) –

+0

開始我已經做到了,但它仍然跳 – MadProgrammer