Java ignores VK_Enter event generated by robot

前端 未结 3 1421
野性不改
野性不改 2021-01-17 04:11

I\'m writing some integration tests using a robot. I have the robot opening a menu and it should be selecting one of the options form the menu; except the enter key seems t

3条回答
  •  执笔经年
    2021-01-17 04:49

    I finally solved this. I had my robot code running in the event-dispatching thread along with the button effects. This meant that none of the buttons could respond to my robot's action until my robot completed execution.

    I'm not entirely certain why this would prevent my robot from working correctly in this case. I discovered that if I removed the ctrl-F4 command that the robot would respond to the enter command, but it seems as if both commands should have been queued and executed correctly the moment the robot returned. I assume either there is a limit to the number of events queued or that I somehow ended up with a datarace between the two events. Either way by moving my robot into a separate thread I get the desired behavior.

    incidentally the reason I couldn't create a SSCCE was because I tried to incorporate the robot into a button and I tried having the robot do multiple events at once; but I didn't try a button spawning a robot doing multiple events. To recreate this issue I would have ended up with code just as complex as my original code.

提交回复
热议问题