< prev index next >

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

Print this page
rev 55657 : 8227587: Add internal privileged System.loadLibrary
Reviewed-by: rriggs
   1 /*
   2  * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package com.apple.laf;
  27 
  28 import java.awt.*;
  29 import java.security.AccessController;
  30 
  31 import javax.swing.*;
  32 import javax.swing.plaf.ComponentUI;
  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


   1 /*
   2  * Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package com.apple.laf;
  27 
  28 import java.awt.*;
  29 import java.security.AccessController;
  30 
  31 import javax.swing.*;
  32 import javax.swing.plaf.ComponentUI;
  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         jdk.internal.access.SharedSecrets.getJavaLangAccess().loadLibrary("osxui");




  43     }
  44 
  45     // Utilities
  46     public void uninstallUI(final JComponent c) {
  47         if (fScreenMenuBar != null) {
  48             final JFrame frame = (JFrame)(c.getTopLevelAncestor());
  49             if (frame != null && frame.getMenuBar() == fScreenMenuBar) {
  50                 frame.setMenuBar((MenuBar)null);
  51             }
  52             fScreenMenuBar = null;
  53         }
  54         super.uninstallUI(c);
  55     }
  56 
  57     // Create PLAF
  58     public static ComponentUI createUI(final JComponent c) {
  59         return new AquaMenuBarUI();
  60     }
  61 
  62     // [3320390] -- If the screen menu bar is in use, don't register keyboard actions that


< prev index next >