8162411: Service Menu services 2
authorssadetsky
Wed, 27 Jul 2016 12:03:19 +0300
changeset 41581 f6c9d506d2d6
parent 41580 cc479488428c
child 41582 246512d81eba
8162411: Service Menu services 2 Reviewed-by: prr, mschoene, serb, ahgross
jdk/src/java.desktop/windows/classes/sun/awt/windows/WFramePeer.java
jdk/src/java.desktop/windows/classes/sun/awt/windows/WMenuBarPeer.java
--- a/jdk/src/java.desktop/windows/classes/sun/awt/windows/WFramePeer.java	Thu Jul 21 10:33:56 2016 -0700
+++ b/jdk/src/java.desktop/windows/classes/sun/awt/windows/WFramePeer.java	Wed Jul 27 12:03:19 2016 +0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 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
@@ -153,6 +153,19 @@
     @Override
     public void setMenuBar(MenuBar mb) {
         WMenuBarPeer mbPeer = (WMenuBarPeer) WToolkit.targetToPeer(mb);
+        if (mbPeer != null) {
+            if (mbPeer.framePeer != this) {
+                mb.removeNotify();
+                mb.addNotify();
+                mbPeer = (WMenuBarPeer) WToolkit.targetToPeer(mb);
+                if (mbPeer != null && mbPeer.framePeer != this) {
+                    throw new IllegalStateException("Wrong parent peer");
+                }
+            }
+            if (mbPeer != null) {
+                addChildPeer(mbPeer);
+            }
+        }
         setMenuBar0(mbPeer);
         updateInsets(insets_);
     }
--- a/jdk/src/java.desktop/windows/classes/sun/awt/windows/WMenuBarPeer.java	Thu Jul 21 10:33:56 2016 -0700
+++ b/jdk/src/java.desktop/windows/classes/sun/awt/windows/WMenuBarPeer.java	Wed Jul 27 12:03:19 2016 +0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 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
@@ -31,6 +31,8 @@
 
     // MenuBarPeer implementation
 
+    final WFramePeer framePeer;
+
     @Override
     public native void addMenu(Menu m);
     @Override
@@ -44,8 +46,11 @@
     // Toolkit & peer internals
     WMenuBarPeer(MenuBar target) {
         this.target = target;
-        WFramePeer framePeer = (WFramePeer)
+        framePeer = (WFramePeer)
             WToolkit.targetToPeer(target.getParent());
+        if (framePeer != null) {
+            framePeer.addChildPeer(this);
+        }
         create(framePeer);
         // fix for 5088782: check if menu object is created successfully
         checkMenuCreation();