Program: 77853
Project: 77853
Buggy source:
private Rectangle createDraggableRectangle(double x,double y,double width,double height){
  final double handleRadius=10;
  Rectangle rect=new Rectangle(x,y,width,height);
  rect.setOpacity(0.1);
  rect.setVisible(true);
  resizeHandleNW=new Circle(handleRadius,Color.BLACK);
  resizeHandleNW.centerXProperty().bind(rect.xProperty());
  resizeHandleNW.centerYProperty().bind(rect.yProperty());
  resizeHandleNW.setVisible(true);
  resizeHandleSE=new Circle(handleRadius,Color.BLACK);
  resizeHandleSE.centerXProperty().bind(rect.xProperty().add(rect.widthProperty()));
  resizeHandleSE.centerYProperty().bind(rect.yProperty().add(rect.heightProperty()));
  resizeHandleSE.setVisible(true);
  rect.parentProperty().addListener((obs,oldParent,newParent) -> {
    for (    Circle c : Arrays.asList(resizeHandleNW,resizeHandleSE)) {
      Pane currentParent=(Pane)c.getParent();
      if (currentParent != null) {
        currentParent.getChildren().remove(c);
      }
      ((Pane)newParent).getChildren().add(c);
    }
  }
);
  Wrapper<Point2D> mouseLocation=new Wrapper<>();
  setUpDragging(resizeHandleNW,mouseLocation);
  setUpDragging(resizeHandleSE,mouseLocation);
  resizeHandleNW.setOnMouseDragged(event -> {
    if (mouseLocation.value != null) {
      double deltaX=event.getSceneX() - mouseLocation.value.getX();
      double deltaY=event.getSceneY() - mouseLocation.value.getY();
      double newX=rect.getX() + deltaX;
      if (newX >= handleRadius && newX <= rect.getX() + rect.getWidth() - handleRadius) {
        rect.setX(newX);
        rect.setWidth(rect.getWidth() - deltaX);
      }
      double newY=rect.getY() + deltaY;
      if (newY >= handleRadius && newY <= rect.getY() + rect.getHeight() - handleRadius) {
        rect.setY(newY);
        rect.setHeight(rect.getHeight() - deltaY);
      }
      mouseLocation.value=new Point2D(event.getSceneX(),event.getSceneY());
    }
  }
);
  resizeHandleSE.setOnMouseDragged(event -> {
    if (mouseLocation.value != null) {
      double deltaX=event.getSceneX() - mouseLocation.value.getX();
      double deltaY=event.getSceneY() - mouseLocation.value.getY();
      double newMaxX=rect.getX() + rect.getWidth() + deltaX;
      if (newMaxX >= rect.getX() && newMaxX <= rect.getParent().getBoundsInLocal().getWidth() - handleRadius) {
        rect.setWidth(rect.getWidth() + deltaX);
      }
      double newMaxY=rect.getY() + rect.getHeight() + deltaY;
      if (newMaxY >= rect.getY() && newMaxY <= rect.getParent().getBoundsInLocal().getHeight() - handleRadius) {
        rect.setHeight(rect.getHeight() + deltaY);
      }
      mouseLocation.value=new Point2D(event.getSceneX(),event.getSceneY());
    }
  }
);
  return rect;
}

Fixed version (ground truth):
private Rectangle createDraggableRectangle(double x,double y,double width,double height){
  final double handleRadius=10;
  Rectangle rect=new Rectangle(x,y,width,height);
  rect.setOpacity(0.1);
  rect.setVisible(true);
  resizeHandleNW=new Circle(handleRadius,Color.BLACK);
  resizeHandleNW.centerXProperty().bind(rect.xProperty());
  resizeHandleNW.centerYProperty().bind(rect.yProperty());
  resizeHandleNW.setVisible(true);
  resizeHandleSE=new Circle(handleRadius,Color.BLACK);
  resizeHandleSE.centerXProperty().bind(rect.xProperty().add(rect.widthProperty()));
  resizeHandleSE.centerYProperty().bind(rect.yProperty().add(rect.heightProperty()));
  resizeHandleSE.setVisible(true);
  rect.parentProperty().addListener((obs,oldParent,newParent) -> {
    for (    Circle c : Arrays.asList(resizeHandleNW,resizeHandleSE)) {
      Pane currentParent=(Pane)c.getParent();
      if (currentParent != null) {
        currentParent.getChildren().remove(c);
      }
      ((Pane)newParent).getChildren().add(c);
    }
  }
);
  Wrapper<Point2D> mouseLocation=new Wrapper<>();
  setUpDragging(resizeHandleNW,mouseLocation);
  setUpDragging(resizeHandleSE,mouseLocation);
  resizeHandleNW.setOnDragDetected(event -> {
    if (mouseLocation.value != null) {
      double deltaX=event.getSceneX() - mouseLocation.value.getX();
      double deltaY=event.getSceneY() - mouseLocation.value.getY();
      double newX=rect.getX() + deltaX;
      if (newX >= handleRadius && newX <= rect.getX() + rect.getWidth() - handleRadius) {
        rect.setX(newX);
        rect.setWidth(rect.getWidth() - deltaX);
      }
      double newY=rect.getY() + deltaY;
      if (newY >= handleRadius && newY <= rect.getY() + rect.getHeight() - handleRadius) {
        rect.setY(newY);
        rect.setHeight(rect.getHeight() - deltaY);
      }
      mouseLocation.value=new Point2D(event.getSceneX(),event.getSceneY());
    }
  }
);
  resizeHandleSE.setOnMouseDragged(event -> {
    if (mouseLocation.value != null) {
      double deltaX=event.getSceneX() - mouseLocation.value.getX();
      double deltaY=event.getSceneY() - mouseLocation.value.getY();
      double newMaxX=rect.getX() + rect.getWidth() + deltaX;
      if (newMaxX >= rect.getX() && newMaxX <= rect.getParent().getBoundsInLocal().getWidth() - handleRadius) {
        rect.setWidth(rect.getWidth() + deltaX);
      }
      double newMaxY=rect.getY() + rect.getHeight() + deltaY;
      if (newMaxY >= rect.getY() && newMaxY <= rect.getParent().getBoundsInLocal().getHeight() - handleRadius) {
        rect.setHeight(rect.getHeight() + deltaY);
      }
      mouseLocation.value=new Point2D(event.getSceneX(),event.getSceneY());
    }
  }
);
  return rect;
}