src/java.desktop/macosx/classes/com/apple/laf/ScreenMenuItem.java

Print this page

        

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

@@ -25,19 +25,22 @@
 
 package com.apple.laf;
 
 import java.awt.*;
 import java.awt.event.*;
-import java.awt.peer.MenuComponentPeer;
 
 import javax.swing.*;
 import javax.swing.plaf.ComponentUI;
 
+import sun.awt.AWTAccessor;
 import sun.lwawt.macosx.CMenuItem;
 
 @SuppressWarnings("serial") // JDK implementation class
-final class ScreenMenuItem extends MenuItem implements ActionListener, ComponentListener, ScreenMenuPropertyHandler {
+final class ScreenMenuItem extends MenuItem
+        implements ActionListener, ComponentListener,
+                   ScreenMenuPropertyHandler {
+
     ScreenMenuPropertyListener fListener;
     JMenuItem fMenuItem;
 
     ScreenMenuItem(final JMenuItem mi) {
         super(mi.getText());

@@ -95,13 +98,12 @@
         fMenuItem.removePropertyChangeListener(fListener);
         fListener = null;
         fMenuItem.removeComponentListener(this);
     }
 
-    @SuppressWarnings("deprecation")
     static void syncLabelAndKS(MenuItem menuItem, String label, KeyStroke ks) {
-        final MenuComponentPeer peer = menuItem.getPeer();
+        Object peer = AWTAccessor.getMenuComponentAccessor().getPeer(menuItem);
         if (!(peer instanceof CMenuItem)) {
             //Is it possible?
             return;
         }
         final CMenuItem cmi = (CMenuItem) peer;

@@ -164,22 +166,20 @@
         if (parent != null) {
             ((ScreenMenuPropertyHandler)parent).setChildVisible(fMenuItem, b);
         }
     }
 
-    @SuppressWarnings("deprecation")
     public void setToolTipText(final String text) {
-        final MenuComponentPeer peer = getPeer();
+        Object peer = AWTAccessor.getMenuComponentAccessor().getPeer(this);
         if (!(peer instanceof CMenuItem)) return;
 
         final CMenuItem cmi = (CMenuItem)peer;
         cmi.setToolTipText(text);
     }
 
-    @SuppressWarnings("deprecation")
     public void setIcon(final Icon i) {
-        final MenuComponentPeer peer = getPeer();
+        Object peer = AWTAccessor.getMenuComponentAccessor().getPeer(this);
         if (!(peer instanceof CMenuItem)) return;
 
         final CMenuItem cmi = (CMenuItem)peer;
             Image img = null;