--- a/jdk/src/java.desktop/share/classes/java/awt/MenuBar.java Tue Jan 13 16:09:21 2015 +0300
+++ b/jdk/src/java.desktop/share/classes/java/awt/MenuBar.java Tue Jan 13 17:10:28 2015 +0300
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 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
@@ -181,7 +181,7 @@
* removed from the menu bar, and replaced with the specified menu.
* @param m the menu to be set as the help menu
*/
- public void setHelpMenu(Menu m) {
+ public void setHelpMenu(final Menu m) {
synchronized (getTreeLock()) {
if (helpMenu == m) {
return;
@@ -189,11 +189,11 @@
if (helpMenu != null) {
remove(helpMenu);
}
- if (m.parent != this) {
- add(m);
- }
helpMenu = m;
if (m != null) {
+ if (m.parent != this) {
+ add(m);
+ }
m.isHelpMenu = true;
m.parent = this;
MenuBarPeer peer = (MenuBarPeer)this.peer;
@@ -242,7 +242,7 @@
* @param index the position of the menu to be removed.
* @see java.awt.MenuBar#add(java.awt.Menu)
*/
- public void remove(int index) {
+ public void remove(final int index) {
synchronized (getTreeLock()) {
Menu m = getMenu(index);
menus.removeElementAt(index);
@@ -252,6 +252,10 @@
m.parent = null;
peer.delMenu(index);
}
+ if (helpMenu == m) {
+ helpMenu = null;
+ m.isHelpMenu = false;
+ }
}
}