src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformWindow.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

@@ -29,16 +29,15 @@
 import java.awt.Dialog.ModalityType;
 import java.awt.event.*;
 import java.awt.peer.WindowPeer;
 import java.beans.*;
 import java.lang.reflect.InvocationTargetException;
-import java.util.List;
-import java.util.Objects;
 
 import javax.swing.*;
 
 import sun.awt.*;
+import sun.awt.AWTAccessor.ComponentAccessor;
 import sun.java2d.SurfaceData;
 import sun.java2d.opengl.CGLSurfaceData;
 import sun.lwawt.*;
 import sun.util.logging.PlatformLogger;
 

@@ -191,12 +190,13 @@
         }}
     }) {
         @SuppressWarnings("deprecation")
         public CPlatformWindow convertJComponentToTarget(final JRootPane p) {
             Component root = SwingUtilities.getRoot(p);
-            if (root == null || (LWWindowPeer)root.getPeer() == null) return null;
-            return (CPlatformWindow)((LWWindowPeer)root.getPeer()).getPlatformWindow();
+            final ComponentAccessor acc = AWTAccessor.getComponentAccessor();
+            if (root == null || acc.getPeer(root) == null) return null;
+            return (CPlatformWindow)((LWWindowPeer)acc.getPeer(root)).getPlatformWindow();
         }
     };
 
     // Bounds of the native widget but in the Java coordinate system.
     // In order to keep it up-to-date we will update them on

@@ -518,19 +518,19 @@
     public boolean isVisible() {
         return this.visible;
     }
 
     @Override // PlatformWindow
-    @SuppressWarnings("deprecation")
     public void setVisible(boolean visible) {
         final long nsWindowPtr = getNSWindowPtr();
 
         // Process parent-child relationship when hiding
+        final ComponentAccessor acc = AWTAccessor.getComponentAccessor();
         if (!visible) {
             // Unparent my children
             for (Window w : target.getOwnedWindows()) {
-                WindowPeer p = (WindowPeer)w.getPeer();
+                WindowPeer p = acc.getPeer(w);
                 if (p instanceof LWWindowPeer) {
                     CPlatformWindow pw = (CPlatformWindow)((LWWindowPeer)p).getPlatformWindow();
                     if (pw != null && pw.isVisible()) {
                         CWrapper.NSWindow.removeChildWindow(nsWindowPtr, pw.getNSWindowPtr());
                     }

@@ -622,11 +622,11 @@
                 applyWindowLevel(target);
             }
 
             // Add my own children to myself
             for (Window w : target.getOwnedWindows()) {
-                WindowPeer p = (WindowPeer)w.getPeer();
+                final Object p = acc.getPeer(w);
                 if (p instanceof LWWindowPeer) {
                     CPlatformWindow pw = (CPlatformWindow)((LWWindowPeer)p).getPlatformWindow();
                     if (pw != null && pw.isVisible()) {
                         CWrapper.NSWindow.addChildWindow(nsWindowPtr, pw.getNSWindowPtr(), CWrapper.NSWindow.NSWindowAbove);
                         pw.applyWindowLevel(w);

@@ -674,17 +674,17 @@
         final long nsWindowPtr = getNSWindowPtr();
         nativePushNSWindowToBack(nsWindowPtr);
     }
 
     @Override  // PlatformWindow
-    @SuppressWarnings("deprecation")
     public void toFront() {
         final long nsWindowPtr = getNSWindowPtr();
         LWCToolkit lwcToolkit = (LWCToolkit) Toolkit.getDefaultToolkit();
         Window w = DefaultKeyboardFocusManager.getCurrentKeyboardFocusManager().getActiveWindow();
-        if( w != null && w.getPeer() != null
-                && ((LWWindowPeer)w.getPeer()).getPeerType() == LWWindowPeer.PeerType.EMBEDDED_FRAME
+        final ComponentAccessor acc = AWTAccessor.getComponentAccessor();
+        if( w != null && acc.getPeer(w) != null
+                && ((LWWindowPeer)acc.getPeer(w)).getPeerType() == LWWindowPeer.PeerType.EMBEDDED_FRAME
                 && !lwcToolkit.isApplicationActive()) {
             lwcToolkit.activateApplicationIgnoringOtherApps();
         }
         updateFocusabilityForAutoRequestFocus(false);
         nativePushNSWindowToFront(nsWindowPtr);