Skip to content

Commit

Permalink
Avoid asynchronous task when calculating relative locations
Browse files Browse the repository at this point in the history
The getRelativeLocation() asynchronously calculates the screen location
of the parent and child component. To calls should instead be done
synchronously, to avoid any race conditions caused by window changes
between those calls.

Amends bee6c0d
  • Loading branch information
ptziegler committed Jul 28, 2024
1 parent bee6c0d commit 7edd08f
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -314,8 +314,8 @@ public static Point getRelativeLocation(final Component parentComponent, final C
throws Exception {
try {
return runObjectLaterAndWait(() -> {
Point parentLocation = getScreenLocation(parentComponent);
Point childLocation = getScreenLocation(childComponent);
Point parentLocation = parentComponent.getLocationOnScreen();
Point childLocation = childComponent.getLocationOnScreen();
int relX = childLocation.x - parentLocation.x;
int relY = childLocation.y - parentLocation.y;
return new Point(relX, relY);
Expand Down

0 comments on commit 7edd08f

Please sign in to comment.