Skip to content

Instantly share code, notes, and snippets.

@Tom-Ski
Created April 4, 2014 23:42
Show Gist options
  • Save Tom-Ski/9985220 to your computer and use it in GitHub Desktop.
Save Tom-Ski/9985220 to your computer and use it in GitHub Desktop.
Move JFrame
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