Skip to content

Commit d0bc0db

Browse files
committed
allow null screen location
1 parent 508d0a7 commit d0bc0db

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

sources/net.sf.j2s.java.core/src/java/awt/Window.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3081,14 +3081,16 @@ public void setLocationRelativeTo(Component c) {
30813081
}
30823082
}
30833083

3084-
if ((c != null && !c.isShowing()) || root == null || !root.isShowing()) {
3084+
Point invokerScreenLocation;
3085+
if (c != null && !c.isShowing()
3086+
|| root == null
3087+
|| !root.isShowing()
3088+
|| (invokerScreenLocation = c.getLocationOnScreen()) == null) {
30853089
Dimension paneSize = getSize();
30863090
Point centerPoint = GraphicsEnvironment.getLocalGraphicsEnvironment().getCenterPoint();
30873091
setLocation(centerPoint.x - paneSize.width / 2, centerPoint.y - paneSize.height / 2);
30883092
} else {
30893093
Dimension invokerSize = c.getSize();
3090-
Point invokerScreenLocation = c.getLocationOnScreen();
3091-
30923094
Rectangle windowBounds = getBounds();
30933095
int dx = invokerScreenLocation.x + ((invokerSize.width - windowBounds.width) >> 1);
30943096
int dy = invokerScreenLocation.y + ((invokerSize.height - windowBounds.height) >> 1);

0 commit comments

Comments
 (0)