B4J Question Reading mouse position warning

ThRuST

Well-Known Member
Licensed User
Longtime User
I am adding full screen detection to read the current mouse cursor position by using a timer which works but displays a warning message in the logs. Any assistance for a workaround is appreciated, thanks.

Process globals
Code: Copy
    Dim MousePositionTimer As Timer
    Dim temp,robot As JavaObject
    Dim x,y As Int
    Dim Lbl_PanelTopPosition As Label

Appstart
Code: Copy
MousePositionTimer.Initialize("MousePositionTimer", 1)
    robot = temp.InitializeStatic("com.sun.glass.ui.Application").RunMethodJO("GetApplication",Null).RunMethodJO("createRobot",Null)
    MousePositionTimer.Enabled = True

Code: Copy
Sub MousePositionTimer_tick

        x = robot.RunMethod("getMouseX",Null) ' x position
        y = robot.RunMethod("getMouseY",Null) ' y position
        Lbl_PanelTopPosition.Text = x & " " & y
    
End Sub

Log:
Waiting for debugger to connect...
Program started.
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by anywheresoftware.b4j.object.JavaObject (file:/C:/Dev/B4J/Libraries/JavaObject.jar) to method com.sun.glass.ui.Application.GetApplication()
WARNING: Please consider reporting this to the maintainers of anywheresoftware.b4j.object.JavaObject
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release

I use Java jdk/rne v9.0.1.
 
Thanks, that's good to know so we can all can still use this method. I'ld like to add that optional alternatives might be to use the jAWTRobot or the jNativeHook library which also is useful to track mouse events.
 
Upvote 0
Correction: I am not sure about if Nativehook supports MouseMove event even though it supports Mouseclicks and Keypress events.
 
Upvote 0
@Erel Thanks, I decided in this case to go for a combo with your of course very useful solution and also Roycefers great libraries. That's why I mentioned them :)
 
Upvote 0
Back
Top