When I try to drag a popupwindow an exception appears:
java.lang.IllegalArgumentException: argument type mismatch
I designed the popwindow in SceneBuilder and added two methods for the anchorpane:
setOnMousePressed
-> returns the position of the popupwindowsetOnMouseDragged
->returns the exception.
The first method works fine and the second not. As I can't find a solution although the topic has been covered, I would be very thankful for some help.
Code of the poupwindow:
private static double xOffset = 0;
private static double yOffset = 0;
@FXML
void setOnMouseDragged(MouseDragEvent event) {
Stage window=(Stage)((Node) event.getSource()).getScene().getWindow();
window.setX(event.getScreenX() + xOffset);
window.setY(event.getScreenY() + yOffset);
}
@FXML
void setOnMousePressed(MouseEvent event) {
Stage window=(Stage)((Node) event.getSource()).getScene().getWindow();
xOffset = window.getX() - event.getScreenX();
yOffset = window.getY() - event.getScreenY();
System.out.println("setOnMouseDraggedx:"+xOffset+" yOffset:"+yOffset);
//this method works and prints out x:-419.0 yOffset:-31.0
}