src/java.desktop/macosx/classes/com/apple/laf/ScreenMenuBar.java
Print this page
*** 1,7 ****
/*
! * Copyright (c) 2011, 2014, 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
--- 1,7 ----
/*
! * 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
*** 23,45 ****
* questions.
*/
package com.apple.laf;
- import sun.awt.AWTAccessor;
import sun.lwawt.macosx.CMenuBar;
import java.awt.*;
import java.awt.event.*;
- import java.lang.reflect.*;
- import java.security.*;
import java.util.*;
import javax.swing.*;
@SuppressWarnings("serial") // JDK implementation class
! public class ScreenMenuBar extends MenuBar implements ContainerListener, ScreenMenuPropertyHandler, ComponentListener {
static boolean sJMenuBarHasHelpMenus = false; //$ could check by calling getHelpMenu in a try block
JMenuBar fSwingBar;
Hashtable<JMenu, ScreenMenu> fSubmenus;
--- 23,47 ----
* questions.
*/
package com.apple.laf;
import sun.lwawt.macosx.CMenuBar;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
+ import static sun.awt.AWTAccessor.*;
+
@SuppressWarnings("serial") // JDK implementation class
! public class ScreenMenuBar extends MenuBar
! implements ContainerListener, ScreenMenuPropertyHandler,
! ComponentListener {
!
static boolean sJMenuBarHasHelpMenus = false; //$ could check by calling getHelpMenu in a try block
JMenuBar fSwingBar;
Hashtable<JMenu, ScreenMenu> fSubmenus;
*** 244,269 ****
menu.removeComponentListener(this);
remove(screenMenu);
fSubmenus.remove(menu);
}
- @SuppressWarnings("deprecation")
public Menu add(final Menu m, final int index) {
synchronized (getTreeLock()) {
if (m.getParent() != null) {
m.getParent().remove(m);
}
! final Vector<Menu> menus = AWTAccessor.getMenuBarAccessor().getMenus(this);
menus.insertElementAt(m, index);
! AWTAccessor.getMenuComponentAccessor().setParent(m, this);
! final CMenuBar peer = (CMenuBar)getPeer();
if (peer == null) return m;
peer.setNextInsertionIndex(index);
! if (m.getPeer() == null) {
m.addNotify();
}
peer.setNextInsertionIndex(-1);
return m;
--- 246,272 ----
menu.removeComponentListener(this);
remove(screenMenu);
fSubmenus.remove(menu);
}
public Menu add(final Menu m, final int index) {
synchronized (getTreeLock()) {
if (m.getParent() != null) {
m.getParent().remove(m);
}
! final Vector<Menu> menus = getMenuBarAccessor().getMenus(this);
menus.insertElementAt(m, index);
! final MenuComponentAccessor acc = getMenuComponentAccessor();
! acc.setParent(m, this);
! final CMenuBar peer = acc.getPeer(this);
if (peer == null) return m;
peer.setNextInsertionIndex(index);
! final CMenuBar mPeer = acc.getPeer(m);
! if (mPeer == null) {
m.addNotify();
}
peer.setNextInsertionIndex(-1);
return m;