# HG changeset patch # User peterz # Date 1239093658 -14400 # Node ID c0dfcd9b27f74fe1b95988a3d7009cc31e8004f7 # Parent 3e32bdf43a3529ed449ff2b32acdfab7e260ecb7 6740974: api/javax_swing/PopupFactory/index.html#Ctor[PopupFactory2002] fails with NPE Reviewed-by: malenkov diff -r 3e32bdf43a35 -r c0dfcd9b27f7 jdk/src/share/classes/javax/swing/PopupFactory.java --- 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;