Skip to content

Instantly share code, notes, and snippets.

@k33ptoo
Created August 17, 2017 16:38
Show Gist options
  • Save k33ptoo/baf20606083d1d333bc70b5c1f5bb56c to your computer and use it in GitHub Desktop.
Save k33ptoo/baf20606083d1d333bc70b5c1f5bb56c to your computer and use it in GitHub Desktop.
A snip for making underdecorated Swing Jframes movable
int xy,xx;
//replace sidepane with your control/container to which you want to move
private void sidepaneMouseDragged(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_sidepaneMouseDragged
// TODO add your handling code here:
int x = evt.getXOnScreen();
int y = evt.getYOnScreen();
this.setLocation(x - xx, y - xy);
}//GEN-LAST:event_sidepaneMouseDragged
private void sidepaneMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_sidepaneMousePressed
// TODO add your handling code here:
xx = evt.getX();
xy = evt.getY();
}//GEN-LAST:event_sidepaneMousePressed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment