changeset 1212:68ce3fa2b4c5

6825362: Avoid calling peer.setZOrder on Window instances Reviewed-by: anthony
author dcherepanov
date Mon, 20 Apr 2009 19:18:41 +0400
parents 0d03c3cc2f03
children 9cb0aecf54bd
files src/share/classes/java/awt/Component.java src/share/classes/java/awt/Container.java src/share/classes/java/awt/Window.java src/windows/classes/sun/awt/windows/WPanelPeer.java
diffstat 4 files changed, 13 insertions(+), 43 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/java/awt/Component.java	Mon Apr 20 17:05:34 2009 +0400
+++ b/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/src/share/classes/java/awt/Container.java	Mon Apr 20 17:05:34 2009 +0400
+++ b/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/src/share/classes/java/awt/Window.java	Mon Apr 20 17:05:34 2009 +0400
+++ b/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/src/windows/classes/sun/awt/windows/WPanelPeer.java	Mon Apr 20 17:05:34 2009 +0400
+++ b/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;
-    }
 }