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

Print this page

        

@@ -39,10 +39,12 @@
 import javax.accessibility.*;
 import javax.swing.plaf.PopupMenuUI;
 import javax.swing.plaf.ComponentUI;
 import javax.swing.plaf.basic.BasicComboPopup;
 import javax.swing.event.*;
+
+import sun.awt.SunToolkit;
 import sun.security.util.SecurityConstants;
 
 import java.applet.Applet;
 
 /**

@@ -345,10 +347,11 @@
         Dimension popupSize = JPopupMenu.this.getPreferredSize();
         long popupRightX = (long)popupLocation.x + (long)popupSize.width;
         long popupBottomY = (long)popupLocation.y + (long)popupSize.height;
         int scrWidth = scrBounds.width;
         int scrHeight = scrBounds.height;
+
         if (!canPopupOverlapTaskBar()) {
             // Insets include the task bar. Take them into account.
             Insets scrInsets = toolkit.getScreenInsets(gc);
             scrBounds.x += scrInsets.left;
             scrBounds.y += scrInsets.top;

@@ -405,29 +408,23 @@
         }
         return gc;
     }
 
     /**
-     * Checks that there are enough security permissions
-     * to make popup "always on top", which allows to show it above the task bar.
+     * Returns whether popup is allowed to be shown above the task bar.
      */
     static boolean canPopupOverlapTaskBar() {
         boolean result = true;
-        try {
-            SecurityManager sm = System.getSecurityManager();
-            if (sm != null) {
-                sm.checkPermission(
-                    SecurityConstants.AWT.SET_WINDOW_ALWAYS_ON_TOP_PERMISSION);
-            }
-        } catch (SecurityException se) {
-            // There is no permission to show popups over the task bar
-            result = false;
+
+        Toolkit tk = Toolkit.getDefaultToolkit();
+        if (tk instanceof SunToolkit) {
+            result = ((SunToolkit)tk).canPopupOverlapTaskBar();
         }
+
         return result;
     }
 
-
     /**
      * Factory method which creates the <code>JMenuItem</code> for
      * <code>Actions</code> added to the <code>JPopupMenu</code>.
      *
      * @param a the <code>Action</code> for the menu item to be added