Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.*;
- import java.awt.event.*;
- public class MousePositionTracker extends MouseMotionAdapter {
- private Point pos;
- private int x=0,y=0;
- public synchronized void mouseDragged(MouseEvent e) {
- pos = e.getPoint();
- x = e.getX();
- y = e.getY();
- }
- public synchronized void mouseMoved(MouseEvent e) {
- pos = e.getPoint();
- x = e.getX();
- y = e.getY();
- }
- public synchronized Point getPosition() {
- if (pos == null) return new Point(0,0);
- return pos;
- }
- public synchronized int getX() {
- return x;
- }
- public synchronized int getY() {
- return y;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement