From 406119889a5b2442c31e7ed82ef085f057ff6310 Mon Sep 17 00:00:00 2001 From: Peter Zhelezniakov Date: Tue, 7 Apr 2009 12:40:58 +0400 Subject: [PATCH] 6740974: api/javax_swing/PopupFactory/index.html#Ctor[PopupFactory2002] fails with NPE Reviewed-by: malenkov --- jdk/src/share/classes/javax/swing/PopupFactory.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/jdk/src/share/classes/javax/swing/PopupFactory.java b/jdk/src/share/classes/javax/swing/PopupFactory.java index 753959cea1f..1eb6d1b5405 100644 --- a/jdk/src/share/classes/javax/swing/PopupFactory.java +++ b/jdk/src/share/classes/javax/swing/PopupFactory.java @@ -552,14 +552,15 @@ public class PopupFactory { boolean result = false; Component component = getComponent(); if (owner != null && component != null) { - Container parent = (Container) SwingUtilities.getRoot(owner); int popupWidth = component.getWidth(); int popupHeight = component.getHeight(); - Rectangle parentBounds = parent.getBounds(); + + Container parent = (Container) SwingUtilities.getRoot(owner); if (parent instanceof JFrame || parent instanceof JDialog || parent instanceof JWindow) { + Rectangle parentBounds = parent.getBounds(); Insets i = parent.getInsets(); parentBounds.x += i.left; parentBounds.y += i.top; @@ -577,11 +578,11 @@ public class PopupFactory { .contains(x, y, popupWidth, popupHeight); } } else if (parent instanceof JApplet) { + Rectangle parentBounds = parent.getBounds(); Point p = parent.getLocationOnScreen(); parentBounds.x = p.x; parentBounds.y = p.y; - result = parentBounds - .contains(x, y, popupWidth, popupHeight); + result = parentBounds.contains(x, y, popupWidth, popupHeight); } } return result;