6740974: api/javax_swing/PopupFactory/index.html#Ctor[PopupFactory2002] fails with NPE

Reviewed-by: malenkov
This commit is contained in:
Peter Zhelezniakov 2009-04-07 12:40:58 +04:00
parent 2c63f90f19
commit 406119889a

View File

@ -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;