--- old/src/share/classes/javax/swing/PopupFactory.java 2014-05-28 11:09:45.000000000 +0400 +++ new/src/share/classes/javax/swing/PopupFactory.java 2014-05-28 11:09:45.000000000 +0400 @@ -25,10 +25,14 @@ package javax.swing; +import sun.awt.EmbeddedFrame; +import sun.awt.OSInfo; + import java.applet.Applet; import java.awt.*; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; +import java.security.AccessController; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -226,7 +230,12 @@ case MEDIUM_WEIGHT_POPUP: return getMediumWeightPopup(owner, contents, ownerX, ownerY); case HEAVY_WEIGHT_POPUP: - return getHeavyWeightPopup(owner, contents, ownerX, ownerY); + Popup popup = getHeavyWeightPopup(owner, contents, ownerX, ownerY); + if ((AccessController.doPrivileged(OSInfo.getOSTypeAction()) == + OSInfo.OSType.MACOSX) && (EmbeddedFrame.getAppletIfAncestorOf(owner) != null)) { + ((HeavyWeightPopup)popup).setCacheEnabled(false); + } + return popup; } return null; } @@ -294,6 +303,8 @@ private static final Object heavyWeightPopupCacheKey = new StringBuffer("PopupFactory.heavyWeightPopupCache"); + private volatile boolean isCacheEnabled = true; + /** * Returns either a new or recycled Popup containing * the specified children. @@ -448,12 +459,23 @@ } } + /** + * Enables or disables cache for current object. + */ + void setCacheEnabled(boolean enable) { + isCacheEnabled = enable; + } + // // Popup methods // public void hide() { super.hide(); - recycleHeavyWeightPopup(this); + if (isCacheEnabled) { + recycleHeavyWeightPopup(this); + } else { + this._dispose(); + } } /**