Created
August 17, 2017 16:38
-
-
Save k33ptoo/baf20606083d1d333bc70b5c1f5bb56c to your computer and use it in GitHub Desktop.
A snip for making underdecorated Swing Jframes movable
This file contains 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
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