changeset 1090:be3afc0e5775

6740974: api/javax_swing/PopupFactory/index.html#Ctor[PopupFactory2002] fails with NPE Reviewed-by: malenkov
author peterz
date Tue, 07 Apr 2009 12:40:58 +0400
parents ce3262ac93fa
children 1729e34a0287
files src/share/classes/javax/swing/PopupFactory.java
diffstat 1 files changed, 5 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/javax/swing/PopupFactory.java	Mon Apr 06 13:06:24 2009 +0400
+++ b/src/share/classes/javax/swing/PopupFactory.java	Tue Apr 07 12:40:58 2009 +0400
@@ -552,14 +552,15 @@
             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 @@
                                 .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;