getPos with MouseListener
Hello. I磎 trying to get the x and y values of the mouse when it磗 pressed. But I dont know how to get the values where I whant them.
I have made put the variables like this(-1 for a start to not exist):
privateint posX;
privateint posY;
public View(){
posX = -1;
posY = -1;
}
Then I guess I have to make a MouseListener method like this:
publicclass Posimplements MouseListener{
publicvoid mousePressed(MouseEvent event){
//get the x and y in px
int posX = event.getX();
int posY = event.getY();
}
publicvoid mouseReleased(MouseEvent event){}
publicvoid mouseClicked(MouseEvent event){}
publicvoid mouseEntered(MouseEvent event){}
publicvoid mouseExited(MouseEvent event){}
}
But now I dont know how to get the "posX" and "posY" values to another method.
If it should be to just write "posX", tell me and I post the whole class instead.

