Skip to content

Instantly share code, notes, and snippets.

@DovgaNik
Last active August 3, 2021 19:51
Show Gist options
  • Save DovgaNik/37aed36f67f3210bb431056169a1b53d to your computer and use it in GitHub Desktop.
Save DovgaNik/37aed36f67f3210bb431056169a1b53d to your computer and use it in GitHub Desktop.
This code will allow you moving undecorated frames in Java Swing
int xMouse;
int yMouse;
private void formMousePressed(java.awt.event.MouseEvent evt) {
xMouse = evt.getX();
yMouse = evt.getY();
}
private void formMouseDragged(java.awt.event.MouseEvent evt) {
int x = evt.getXOnScreen();
int y = evt.getYOnScreen();
this.setLocation(x - xMouse, y - yMouse);
}
//*************************************************
//*Made by DovgaNik in 2020 *
//*Create event mousePressed for frame in your IDE*
//*Create event mouseDragged for frame in your IDE*
//*************************************************
@DovgaNik
Copy link
Author

DovgaNik commented Aug 3, 2021

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment