< prev index next >
src/java.desktop/share/classes/javax/swing/UIDefaults.java
Print this page
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, 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
@@ -48,10 +48,11 @@
import java.awt.Dimension;
import java.beans.PropertyChangeListener;
import java.security.AccessController;
import java.security.AccessControlContext;
import java.security.PrivilegedAction;
+import sun.awt.OSInfo;
import sun.reflect.misc.MethodUtil;
import sun.reflect.misc.ReflectUtil;
import sun.swing.SwingUtilities2;
@@ -89,10 +90,34 @@
* Access to this should be done while holding a lock on the
* UIDefaults, eg synchronized(this).
*/
private Map<Locale, Map<String, Object>> resourceCache;
+ private static boolean disableAquaMenuBarUI = true;
+
+ static {
+ AccessController
+ .doPrivileged((PrivilegedAction<Void>) () -> {
+ if (OSInfo.getOSType() == OSInfo.OSType.MACOSX
+ && !Boolean.getBoolean("apple.laf.disableForcedScreenMenuBar")) {
+
+ try {
+ Class<?> cls = Class.forName("com.apple.laf.AquaMenuBarUI");
+ Method m = cls.getDeclaredMethod("getScreenMenuBarProperty");
+ m.setAccessible(true);
+
+ disableAquaMenuBarUI = !((boolean) m.invoke(null));
+ } catch (Exception ignored) {}
+
+ if (!disableAquaMenuBarUI) {
+ System.loadLibrary("osxui");
+ }
+ }
+ return null;
+ });
+ }
+
/**
* Creates an empty defaults table.
*/
public UIDefaults() {
this(700, .75f);
@@ -396,10 +421,15 @@
}
else {
super.put(keyValueList[i], value);
}
}
+
+ if (!disableAquaMenuBarUI) {
+ UIManager.put("MenuBarUI", "com.apple.laf.AquaMenuBarUI");
+ }
+
firePropertyChange("UIDefaults", null, null);
}
/**
< prev index next >