src/java.desktop/macosx/classes/com/apple/eawt/_AppMenuBarHandler.java
Print this page
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2015, 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
@@ -30,10 +30,11 @@
import javax.swing.*;
import javax.swing.plaf.MenuBarUI;
import com.apple.laf.ScreenMenuBar;
+import sun.awt.AWTAccessor;
import sun.lwawt.macosx.CMenuBar;
import com.apple.laf.AquaMenuBarUI;
class _AppMenuBarHandler {
@@ -47,11 +48,14 @@
static _AppMenuBarHandler getInstance() {
return instance;
}
// callback from the native delegate -init function
- private static void initMenuStates(final boolean aboutMenuItemVisible, final boolean aboutMenuItemEnabled, final boolean prefsMenuItemVisible, final boolean prefsMenuItemEnabled) {
+ private static void initMenuStates(final boolean aboutMenuItemVisible,
+ final boolean aboutMenuItemEnabled,
+ final boolean prefsMenuItemVisible,
+ final boolean prefsMenuItemEnabled) {
synchronized (instance) {
instance.aboutMenuItemVisible = aboutMenuItemVisible;
instance.aboutMenuItemEnabled = aboutMenuItemEnabled;
instance.prefsMenuItemVisible = prefsMenuItemVisible;
instance.prefsMenuItemEnabled = prefsMenuItemEnabled;
@@ -90,11 +94,10 @@
static boolean isFrameMinimized(final Frame frame) {
return (frame.getExtendedState() & Frame.ICONIFIED) != 0;
}
- @SuppressWarnings("deprecation")
static void installDefaultMenuBar(final JMenuBar menuBar) {
if (menuBar == null) {
// intentionally clearing the default menu
nativeSetDefaultMenuBar(0);
return;
@@ -112,11 +115,11 @@
// Aqua is installed, but we aren't using the screen menu bar
throw new IllegalStateException("Application.setDefaultMenuBar() only works if apple.laf.useScreenMenuBar=true");
}
screenMenuBar.addNotify();
- final MenuComponentPeer peer = screenMenuBar.getPeer();
+ final Object peer = AWTAccessor.getMenuComponentAccessor().getPeer(screenMenuBar);
if (!(peer instanceof CMenuBar)) {
// such a thing should not be possible
throw new IllegalStateException("Unable to determine native menu bar from provided JMenuBar");
}