Created
June 27, 2020 05:27
-
-
Save tsathis/cc16e1a224e2a639badf790ddcf05fc4 to your computer and use it in GitHub Desktop.
Drag an undecorated window of JavaFX ##javafx
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
@FXML | |
private StackPane parentPane; | |
double xOffset; | |
double yOffset; | |
@FXML | |
void handleOnMouseDraggedBtnCtrlMainView(MouseEvent event) { | |
Stage stage = ( Stage ) parentPane.getScene().getWindow(); | |
stage.setX(event.getScreenX() + xOffset); | |
stage.setY(event.getScreenY() + yOffset); | |
} | |
@FXML | |
void handleOnMousePressedBtnCtrlMainView(MouseEvent event) { | |
Stage stage = ( Stage ) parentPane.getScene().getWindow(); | |
xOffset = stage.getX() - event.getScreenX(); | |
yOffset = stage.getY() - event.getScreenY(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment