src/java.desktop/macosx/classes/com/apple/eawt/_AppDockIconHandler.java

Print this page

        

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 2011, 2012, 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

@@ -26,10 +26,11 @@
 package com.apple.eawt;
 
 import java.awt.*;
 import java.lang.reflect.*;
 
+import sun.awt.AWTAccessor;
 import sun.lwawt.macosx.*;
 import sun.lwawt.macosx.CImage.Creator;
 
 class _AppDockIconHandler {
     private static native void nativeSetDockMenu(final long cmenu);

@@ -39,11 +40,10 @@
 
     PopupMenu fDockMenu = null;
 
     _AppDockIconHandler() { }
 
-    @SuppressWarnings("deprecation")
     public void setDockMenu(final PopupMenu menu) {
         fDockMenu = menu;
 
         // clear the menu if explicitly passed null
         if (menu == null) {

@@ -59,12 +59,12 @@
             newParent.addNotify();
         }
 
         // instantiate the menu peer and set the native fDockMenu ivar
         menu.addNotify();
-        final long nsMenuPtr = ((CMenu)fDockMenu.getPeer()).getNativeMenu();
-        nativeSetDockMenu(nsMenuPtr);
+        CMenu peer = AWTAccessor.getMenuComponentAccessor().getPeer(fDockMenu);
+        nativeSetDockMenu(peer.getNativeMenu());
     }
 
     public PopupMenu getDockMenu() {
         return fDockMenu;
     }