void (@NotNull Component draggedComp, @NotNull Point mouseLocation) { // Get the mouse location on the correct screen, in the correct screen coordinates Point screenMouseLocation = new DevicePoint(mouseLocation, draggedComp).getLocationOnScreen(); Dimension originalSize = draggedComp.getSize(); Point newLocation = new Point(screenMouseLocation.x - myInitialOffset.x, screenMouseLocation.y - myInitialOffset.y); draggedComp.setLocation(newLocation); // Windows can resize the window when it crosses the boundary between two screens with different DPI. It tries to keep the same physical // size, based on DPI, so moving from a large DPI scale factor to a lower factor (e.g. 150% to 100%) will cause the window to shrink. By // shrinking, it's now not on the boundary anymore, but Windows doesn't update the scale. Continuing to drag will cross the boundary // again, and it will shrink again. This repeats until the window vanishes. Going in the opposite direction can cause the window to grow // huge. We don't scale the UI, so keep it to the same original size // Note that there looks like a bug in the JBR that causes the window to jump to a weirdly large x value, as though it's being scaled // multiple times. See the note in ToolWindowDragHelper.relocate for more if (draggedComp.getSize() != originalSize) { draggedComp.setSize(originalSize); } }