Last active
August 3, 2021 19:51
-
-
Save DovgaNik/37aed36f67f3210bb431056169a1b53d to your computer and use it in GitHub Desktop.
This code will allow you moving undecorated frames in Java Swing
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
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* | |
//************************************************* |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://pastebin.com/xZNyq5wH