8283215: [macos] Screen Magnifier: Getting java.awt.IllegalComponentStateException when menu item is selected

Reviewed-by: serb, prr
This commit is contained in:
Alexander Zuev 2022-04-04 21:22:44 +00:00
parent 86caf606ff
commit 9440b39193

View File

@ -28,6 +28,7 @@ package sun.lwawt.macosx;
import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.IllegalComponentStateException;
import java.awt.KeyboardFocusManager;
import java.awt.Point;
import java.awt.Window;
@ -469,7 +470,16 @@ class CAccessibility implements PropertyChangeListener {
public static Accessible accessibilityHitTest(final Container parent, final float hitPointX, final float hitPointY) {
return invokeAndWait(new Callable<Accessible>() {
public Accessible call() throws Exception {
final Point p = parent.getLocationOnScreen();
if (parent == null) {
return null;
}
final Point p;
try {
p = parent.getLocationOnScreen();
} catch (IllegalComponentStateException ice) {
return null;
}
// Make it into local coords
final Point localPoint = new Point((int)(hitPointX - p.getX()), (int)(hitPointY - p.getY()));