Created
April 4, 2014 23:42
-
-
Save Tom-Ski/9985220 to your computer and use it in GitHub Desktop.
Move JFrame
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
addMouseListener(new MouseAdapter() { | |
public void mousePressed(MouseEvent e) { | |
point.x = e.getX(); | |
point.y = e.getY(); | |
} | |
}); | |
addMouseMotionListener(new MouseMotionAdapter() { | |
public void mouseDragged(MouseEvent e) { | |
Point p = getLocation(); | |
setLocation(p.x + e.getX() - point.x, p.y + e.getY() - point.y); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment