src/share/classes/javax/swing/JPopupMenu.java

Print this page

        

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.  Oracle designates this

@@ -734,11 +734,11 @@
         if(popup != null) {
             Dimension pref = getPreferredSize();
 
             if (pref == null || pref.width != getWidth() ||
                                 pref.height != getHeight()) {
-                popup = getPopup();
+                getPopup();
             } else {
                 validate();
             }
         }
     }

@@ -785,11 +785,11 @@
             }
         }
 
         if(b) {
             firePopupMenuWillBecomeVisible();
-            popup = getPopup();
+            getPopup();
             firePropertyChange("visible", Boolean.FALSE, Boolean.TRUE);
 
 
         } else if(popup != null) {
             firePopupMenuWillBecomeInvisible();

@@ -803,20 +803,20 @@
             }
         }
     }
 
     /**
-     * Returns a <code>Popup</code> instance from the
+     * Retrieves <code>Popup</code> instance from the
      * <code>PopupMenuUI</code> that has had <code>show</code> invoked on
      * it. If the current <code>popup</code> is non-null,
      * this will invoke <code>dispose</code> of it, and then
      * <code>show</code> the new one.
      * <p>
      * This does NOT fire any events, it is up the caller to dispatch
      * the necessary events.
      */
-    private Popup getPopup() {
+    private void getPopup() {
         Popup oldPopup = popup;
 
         if (oldPopup != null) {
             oldPopup.hide();
         }

@@ -836,12 +836,12 @@
 
         Popup newPopup = getUI().getPopup(this, desiredLocationX,
                                           desiredLocationY);
 
         popupFactory.setPopupType(PopupFactory.LIGHT_WEIGHT_POPUP);
+        popup = newPopup;
         newPopup.show();
-        return newPopup;
     }
 
     /**
      * Returns true if the popup menu is visible (currently
      * being displayed).

@@ -871,11 +871,11 @@
         int oldY = desiredLocationY;
 
         desiredLocationX = x;
         desiredLocationY = y;
         if(popup != null && (x != oldX || y != oldY)) {
-            popup = getPopup();
+            getPopup();
         }
     }
 
     /**
      * Returns true if the popup menu is a standalone popup menu

@@ -1028,11 +1028,11 @@
         setPreferredSize(d);
         if (popup != null) {
             Dimension newSize = getPreferredSize();
 
             if (!oldSize.equals(newSize)) {
-                popup = getPopup();
+                getPopup();
             }
         }
     }
 
     /**