There are lots of situations where you want to use the mouse
for something other than controlling the cursor on the screen. For
example, 3D object viewers often use the mouse to rotate your
viewpoint, or a game might use the mouse to steer a spaceship.
I'm trying to figure out how to implement this in Java. To a
first approximation, it's simple. Call Toolkit.createCustomCursor
() to create an invisible cursor. Set that as the cursor on your
window. Now just listen for mouse moves and drags, and respond to
them appropriately.
The problem is that you're still really just moving a cursor
on the screen. You stop getting mouse move events as soon as the
mouse leaves the window. Mouse drag events keep coming, but the
cursor is still limited to the screen dimensions. So you're flying
your spaceship, and suddenly hit a wall! No, it isn't a force
field in space. :) The cursor has just run into the edge of the
screen.
Obviously native applications manage to find a way around this
problem. Does anyone know a way to do it from Java?
Use java.awt.Robot to reposition the cursor into the middle of your
window responding to the move event.
Or use JInput https://jinput.dev.java.net/
Scott
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/java-dev/email@hidden