6740974: api/javax_swing/PopupFactory/index.html#Ctor[PopupFactory2002] fails with NPE
Reviewed-by: malenkov
This commit is contained in:
parent
2c63f90f19
commit
406119889a
@ -552,14 +552,15 @@ public class PopupFactory {
|
|||||||
boolean result = false;
|
boolean result = false;
|
||||||
Component component = getComponent();
|
Component component = getComponent();
|
||||||
if (owner != null && component != null) {
|
if (owner != null && component != null) {
|
||||||
Container parent = (Container) SwingUtilities.getRoot(owner);
|
|
||||||
int popupWidth = component.getWidth();
|
int popupWidth = component.getWidth();
|
||||||
int popupHeight = component.getHeight();
|
int popupHeight = component.getHeight();
|
||||||
Rectangle parentBounds = parent.getBounds();
|
|
||||||
|
Container parent = (Container) SwingUtilities.getRoot(owner);
|
||||||
if (parent instanceof JFrame ||
|
if (parent instanceof JFrame ||
|
||||||
parent instanceof JDialog ||
|
parent instanceof JDialog ||
|
||||||
parent instanceof JWindow) {
|
parent instanceof JWindow) {
|
||||||
|
|
||||||
|
Rectangle parentBounds = parent.getBounds();
|
||||||
Insets i = parent.getInsets();
|
Insets i = parent.getInsets();
|
||||||
parentBounds.x += i.left;
|
parentBounds.x += i.left;
|
||||||
parentBounds.y += i.top;
|
parentBounds.y += i.top;
|
||||||
@ -577,11 +578,11 @@ public class PopupFactory {
|
|||||||
.contains(x, y, popupWidth, popupHeight);
|
.contains(x, y, popupWidth, popupHeight);
|
||||||
}
|
}
|
||||||
} else if (parent instanceof JApplet) {
|
} else if (parent instanceof JApplet) {
|
||||||
|
Rectangle parentBounds = parent.getBounds();
|
||||||
Point p = parent.getLocationOnScreen();
|
Point p = parent.getLocationOnScreen();
|
||||||
parentBounds.x = p.x;
|
parentBounds.x = p.x;
|
||||||
parentBounds.y = p.y;
|
parentBounds.y = p.y;
|
||||||
result = parentBounds
|
result = parentBounds.contains(x, y, popupWidth, popupHeight);
|
||||||
.contains(x, y, popupWidth, popupHeight);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
Loading…
Reference in New Issue
Block a user