6740974: api/javax_swing/PopupFactory/index.html#Ctor[PopupFactory2002] fails with NPE
Reviewed-by: malenkov
--- a/jdk/src/share/classes/javax/swing/PopupFactory.java Mon Apr 06 13:06:24 2009 +0400
+++ b/jdk/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;