< prev index next >

src/java.desktop/macosx/classes/com/apple/laf/AquaMenuBarUI.java

Print this page




  33 import javax.swing.plaf.basic.BasicMenuBarUI;
  34 
  35 import sun.lwawt.macosx.LWCToolkit;
  36 import sun.security.action.GetBooleanAction;
  37 
  38 // MenuBar implementation for Mac L&F
  39 public class AquaMenuBarUI extends BasicMenuBarUI implements ScreenMenuBarProvider {
  40 
  41     static {
  42         java.security.AccessController.doPrivileged(
  43                 (java.security.PrivilegedAction<Void>) () -> {
  44             System.loadLibrary("osxui");
  45             return null;
  46         });
  47     }
  48 
  49     // Utilities
  50     public void uninstallUI(final JComponent c) {
  51         if (fScreenMenuBar != null) {
  52             final JFrame frame = (JFrame)(c.getTopLevelAncestor());
  53             if (frame.getMenuBar() == fScreenMenuBar) {
  54                 frame.setMenuBar((MenuBar)null);
  55             }
  56             fScreenMenuBar = null;
  57         }
  58         super.uninstallUI(c);
  59     }
  60 
  61     // Create PLAF
  62     public static ComponentUI createUI(final JComponent c) {
  63         return new AquaMenuBarUI();
  64     }
  65 
  66     // [3320390] -- If the screen menu bar is in use, don't register keyboard actions that
  67     // show the menus when F10 is pressed.
  68     protected void installKeyboardActions() {
  69         if (!useScreenMenuBar) {
  70             super.installKeyboardActions();
  71         }
  72     }
  73 




  33 import javax.swing.plaf.basic.BasicMenuBarUI;
  34 
  35 import sun.lwawt.macosx.LWCToolkit;
  36 import sun.security.action.GetBooleanAction;
  37 
  38 // MenuBar implementation for Mac L&F
  39 public class AquaMenuBarUI extends BasicMenuBarUI implements ScreenMenuBarProvider {
  40 
  41     static {
  42         java.security.AccessController.doPrivileged(
  43                 (java.security.PrivilegedAction<Void>) () -> {
  44             System.loadLibrary("osxui");
  45             return null;
  46         });
  47     }
  48 
  49     // Utilities
  50     public void uninstallUI(final JComponent c) {
  51         if (fScreenMenuBar != null) {
  52             final JFrame frame = (JFrame)(c.getTopLevelAncestor());
  53             if (frame != null && frame.getMenuBar() == fScreenMenuBar) {
  54                 frame.setMenuBar((MenuBar)null);
  55             }
  56             fScreenMenuBar = null;
  57         }
  58         super.uninstallUI(c);
  59     }
  60 
  61     // Create PLAF
  62     public static ComponentUI createUI(final JComponent c) {
  63         return new AquaMenuBarUI();
  64     }
  65 
  66     // [3320390] -- If the screen menu bar is in use, don't register keyboard actions that
  67     // show the menus when F10 is pressed.
  68     protected void installKeyboardActions() {
  69         if (!useScreenMenuBar) {
  70             super.installKeyboardActions();
  71         }
  72     }
  73 


< prev index next >