Skip to content

Commit f558699

Browse files
committed
getLocationOnScreen() to allow null response when host.peer is null
1 parent 98023a3 commit f558699

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1867,17 +1867,21 @@ public Point getLocationOnScreen() {
18671867
*/
18681868
final Point getLocationOnScreen_NoTreeLock() {
18691869
if (isShowing()) {
1870-
if (isLightweight()) {// peer instanceof LightweightPeer) { // SwingJS will return FALSE
1870+
if (isLightweight()) {
18711871
// lightweight component location needs to be translated
18721872
// relative to a native component.
18731873
Container host = getNativeContainer();
1874+
if (host.peer == null)
1875+
return null;
18741876
Point pt = host.peer.getLocationOnScreen();
18751877
for (Component c = this; c != host; c = c.getParent()) {
18761878
pt.x += c.x;
18771879
pt.y += c.y;
18781880
}
18791881
return pt;
18801882
} else {
1883+
if (peer == null)
1884+
return null;
18811885
Point pt = peer.getLocationOnScreen();
18821886
return pt;
18831887
}

0 commit comments

Comments
 (0)