I want to know where my mouse is everywhere, even if it’s not over my window. I want to know where the mouse is in global coords no matter what. The MouseMotionListener interface only let’s me know where the mouse is if it’s hovering over my window. Any ideas?
you could find the amount of change in the mouse’s position and find the global coordinates from there. This means you keep track of some mousePosition variable in your game instead of using the mouse’s actual position. If you want to do this, you should hide the mouse for one, but will also need to reset the mouse position to the center after you find out how much it changed.
ehh I think you misunderstood my question. I don’t want to limit the movement of the mouse, I want to monitor it. As of right now, I can move my mouse all over the screen and my mouseMoved() method will never be called unless the motion occured directly over my window. I want to be able to monitor mouse motion over the entire screen.
I understand what your looking for and my solution would give it. I think the part that I missed is that you actually want the mouse to leave the window, I figured that was a negative effect of the program.
heres a code example of what I was describing:
public class AClass implements MouseMotionListener
{
private int mouseX;
private int mouseY;
private int screenCenterX;
private int screenCenterY;
public AClass()
{
mouseX = getMouseX();
mouseY = getMouseY();
screenCenterX = getScreenWidth()/2;
screenCenterY = getScreenHeight()/2;
}
public void mouseMoved(MouseEvent e)
{
int dx = screenCenterX-lastX;
int dy = screenCenterY-lastY;
mouseX += dx;
mouseY += dy;
//use java.awt.Robot to move the mouse to
//screenCenterX/screenCenterY
}
}
edit: added the code.
As far as I know… it’s not possible. You can only track movements above your components and movements outside of those components is only possible if it’s a dragging motion, which started inside one of your components.
There’s the java.awt.MouseInfo class, added in 1.5. It allows you to get the location of the mouse pointer anywhere on the screen.
Thanks,
Dmitri
Is there somewhere a list with classes and methods which were added in 1.5?
Weston, in your code, you keep the mouse contained at the center of the screen. Like I said, I don’t want to manipulate it, I want to monitor it. With your code the mouse can’t even leave my window unless I move the mouse really fast at one point in which case the mouseMoved() method would not be called again no matter how I move the mouse until I move it back over my window where it would be re-locked at the center.
I’ll check out the new MouseInfo class, thanks! As this is just for personal use I have no problems with playing with 1.5 classes 
[quote] Is there somewhere a list with classes and methods which were added in 1.5?
[/quote]
Unfortunately, I don’t think so, although I think it’d be quite useful.
A good place to start would be the ReleaseNotes, and if you know
the area you’re interested in (awt in this case), you could get to
http://java.sun.com/j2se/1.5.0/docs/guide/awt/1.5/index.html
Thanks,
Dmitri
A “diff doc” could be generated automatically. All you need is creating a tree with class names and their method signatures… hmm… maybe I’ll do something like that one day (if my todo list ever gets empty ;)).
Well, I know where the docs are. I’m using the api-bot¹ almost each day 
[¹ It’s a quakenet bot, which can be querried for the docs of classes/methods by writing those names (you can also use wildcards). It’s pretty handy.]
Well, the thing is, I’m sure these diffs (or some kind of their equivalent) exist somewhere. For example, SQE and JCK folks need to check that no new apis could be sneaked into a new release…
I’ll ask around…
Dmitri
[quote]A good place to start would be the ReleaseNotes,
[/quote]
Maybe a little better link (the subject list):
http://java.sun.com/j2se/1.5.0/docs/relnotes/features.html