6825362: Avoid calling peer.setZOrder on Window instances
authordcherepanov
Mon, 20 Apr 2009 19:18:41 +0400
changeset 2647 ea80a312972e
parent 2646 ab13ed73d1f5
child 2648 aa45a227fce3
6825362: Avoid calling peer.setZOrder on Window instances Reviewed-by: anthony
jdk/src/share/classes/java/awt/Component.java
jdk/src/share/classes/java/awt/Container.java
jdk/src/share/classes/java/awt/Window.java
jdk/src/windows/classes/sun/awt/windows/WPanelPeer.java
--- a/jdk/src/share/classes/java/awt/Component.java	Mon Apr 20 17:05:34 2009 +0400
+++ b/jdk/src/share/classes/java/awt/Component.java	Mon Apr 20 19:18:41 2009 +0400
@@ -6666,7 +6666,7 @@
 
 
             // Update stacking order
-            peer.setZOrder(getHWPeerAboveMe());
+            updateZOrder();
 
             if (!isAddNotifyComplete) {
                 mixOnShowing();
@@ -9838,4 +9838,11 @@
 
         return doesClassImplement(obj.getClass(), interfaceName);
     }
+
+    // Note that the method is overriden in the Window class,
+    // a window doesn't need to be updated in the Z-order.
+    void updateZOrder() {
+        peer.setZOrder(getHWPeerAboveMe());
+    }
+
 }
--- a/jdk/src/share/classes/java/awt/Container.java	Mon Apr 20 17:05:34 2009 +0400
+++ b/jdk/src/share/classes/java/awt/Container.java	Mon Apr 20 19:18:41 2009 +0400
@@ -840,7 +840,7 @@
                     // Native container changed - need to reparent native widgets
                     newNativeContainer.reparentChild(comp);
                 }
-                comp.peer.setZOrder(comp.getHWPeerAboveMe());
+                comp.updateZOrder();
 
                 if (!comp.isLightweight() && isLightweight()) {
                     // If component is heavyweight and one of the containers is lightweight
--- a/jdk/src/share/classes/java/awt/Window.java	Mon Apr 20 17:05:34 2009 +0400
+++ b/jdk/src/share/classes/java/awt/Window.java	Mon Apr 20 19:18:41 2009 +0400
@@ -3674,6 +3674,10 @@
         }); // WindowAccessor
     } // static
 
+    // a window doesn't need to be updated in the Z-order.
+    @Override
+    void updateZOrder() {}
+
 } // class Window
 
 
--- a/jdk/src/windows/classes/sun/awt/windows/WPanelPeer.java	Mon Apr 20 17:05:34 2009 +0400
+++ b/jdk/src/windows/classes/sun/awt/windows/WPanelPeer.java	Mon Apr 20 19:18:41 2009 +0400
@@ -99,45 +99,4 @@
     public Insets insets() {
         return getInsets();
     }
-
-    private native void pRestack(Object[] peers);
-    private void restack(Container cont, Vector peers) {
-        for (int i = 0; i < cont.getComponentCount(); i++) {
-            Component comp = cont.getComponent(i);
-            if (!comp.isLightweight()) {
-                ComponentPeer peer = comp.getPeer();
-                if (peer != null && (peer instanceof WComponentPeer))
-                {
-                    peers.add(peer);
-                } else {
-                    if (log.isLoggable(Level.FINE)) {
-                        log.log(Level.FINE,
-                                "peer of a {0} is null or not a WComponentPeer: {1}.",
-                                new Object[]{comp, peer});
-                    }
-                }
-            }
-            if (comp.isLightweight() && comp instanceof Container) {
-                restack((Container)comp, peers);
-            }
-        }
-    }
-
-    /**
-     * @see java.awt.peer.ContainerPeer#restack
-     */
-    public void restack() {
-        Vector peers = new Vector();
-        peers.add(this);
-        Container cont = (Container)target;
-        restack(cont, peers);
-        pRestack(peers.toArray());
-    }
-
-    /**
-     * @see java.awt.peer.ContainerPeer#isRestackSupported
-     */
-    public boolean isRestackSupported() {
-        return true;
-    }
 }