Attaching Mouse To Window
How exactly do you attach the mouse to a specified Java window so that the mouse movements are dedicated ONLY to that application?
Ideally, I would like the cursor to remain visible, but only be allowed to remain within the window bounds unless released.
Re: Attaching Mouse To Window
Why do you think you should do this?
You might want to check out the Robot class, but more likely, you should probably rethink your plan.
Re: Attaching Mouse To Window
Quote:
Originally Posted by
KevinWorkman
Why do you think you should do this?
You might want to check out the Robot class, but more likely, you should probably rethink your plan.
Perhaps you misunderstood?
Games do this all the time. The mouse is bound to the program's display so that the movements are registered and processed in the program itslef, not by the rest of the system, until it is released by hitting ESC (or whatever hotkey for pause) or closing the program.
I could see using the robot class to force the mouse to stay in one spot or stay within certain boundaries, but I'm just wondering if there is a better way to do it.
Re: Attaching Mouse To Window
Robot class is the way to go. Or make the game fullscreen.
I know exactly what you're talking about, and it's annoying as heck. There's a reason Java doesn't have a "keepMouseInWindow()" method.