--- old/src/macosx/classes/sun/lwawt/LWComponentPeer.java 2013-04-23 19:12:03.864634800 +0400 +++ new/src/macosx/classes/sun/lwawt/LWComponentPeer.java 2013-04-23 19:12:03.656622900 +0400 @@ -93,12 +93,12 @@ // the container peer is not null, which might also be false if // addNotify() is called for a component outside of the hierarchy. // The exception is LWWindowPeers: their parents are always null - private LWContainerPeer containerPeer; + private final LWContainerPeer containerPeer; // Handy reference to the top-level window peer. Window peer is // borrowed from the containerPeer in constructor, and should also // be updated when the component is reparented to another container - private LWWindowPeer windowPeer; + private final LWWindowPeer windowPeer; private final AtomicBoolean disposed = new AtomicBoolean(false); @@ -183,13 +183,14 @@ this.target = target; this.platformComponent = platformComponent; - initializeContainerPeer(); // Container peer is always null for LWWindowPeers, so // windowPeer is always null for them as well. On the other // hand, LWWindowPeer shouldn't use windowPeer at all - if (containerPeer != null) { - windowPeer = containerPeer.getWindowPeerOrSelf(); - } + final Container parent = SunToolkit.getNativeContainer(target); + containerPeer = (LWContainerPeer) LWToolkit.targetToPeer(parent); + windowPeer = containerPeer != null ? containerPeer.getWindowPeerOrSelf() + : null; + // don't bother about z-order here as updateZOrder() // will be called from addNotify() later anyway if (containerPeer != null) { @@ -356,15 +357,6 @@ return containerPeer; } - // Just a helper method - // Overridden in LWWindowPeer to skip containerPeer initialization - protected void initializeContainerPeer() { - Container parent = LWToolkit.getNativeContainer(target); - if (parent != null) { - containerPeer = (LWContainerPeer) LWToolkit.targetToPeer(parent); - } - } - public PlatformWindow getPlatformWindow() { LWWindowPeer windowPeer = getWindowPeer(); return windowPeer.getPlatformWindow(); --- old/src/macosx/classes/sun/lwawt/LWWindowPeer.java 2013-04-23 19:12:06.138258400 +0400 +++ new/src/macosx/classes/sun/lwawt/LWWindowPeer.java 2013-04-23 19:12:05.897244700 +0400 @@ -201,11 +201,6 @@ return this; } - @Override - protected void initializeContainerPeer() { - // No-op as LWWindowPeer doesn't have any containerPeer - } - // ---- PEER METHODS ---- // @Override --- old/src/share/classes/java/awt/Component.java 2013-04-23 19:12:08.098370600 +0400 +++ new/src/share/classes/java/awt/Component.java 2013-04-23 19:12:07.838355700 +0400 @@ -1051,11 +1051,11 @@ return parent; } - // This method is overriden in the Window class to return null, + // This method is overridden in the Window class to return null, // because the parent field of the Window object contains // the owner of the window, not its parent. Container getContainer() { - return getParent(); + return getParent_NoClientCode(); } /** @@ -8197,7 +8197,7 @@ Container getNativeContainer() { Container p = parent; while (p != null && p.peer instanceof LightweightPeer) { - p = p.getParent_NoClientCode(); + p = p.getContainer(); } return p; } --- old/src/windows/classes/sun/awt/windows/WComponentPeer.java 2013-04-23 19:12:10.764622100 +0400 +++ new/src/windows/classes/sun/awt/windows/WComponentPeer.java 2013-04-23 19:12:10.543609500 +0400 @@ -759,9 +759,7 @@ WComponentPeer(Component target) { this.target = target; this.paintArea = new RepaintArea(); - Container parent = WToolkit.getNativeContainer(target); - WComponentPeer parentPeer = (WComponentPeer) WToolkit.targetToPeer(parent); - create(parentPeer); + create(getNativeParent()); // fix for 5088782: check if window object is created successfully checkCreation(); @@ -769,8 +767,14 @@ initialize(); start(); // Initialize enable/disable state, turn on callbacks } + abstract void create(WComponentPeer parent); + WComponentPeer getNativeParent(){ + Container parent = SunToolkit.getNativeContainer((Component) target); + return (WComponentPeer) WToolkit.targetToPeer(parent); + } + protected void checkCreation() { if ((hwnd == 0) || (pData == 0)) --- old/src/windows/classes/sun/awt/windows/WDialogPeer.java 2013-04-23 19:12:12.691731900 +0400 +++ new/src/windows/classes/sun/awt/windows/WDialogPeer.java 2013-04-23 19:12:12.458718600 +0400 @@ -55,7 +55,7 @@ native void createAwtDialog(WComponentPeer parent); void create(WComponentPeer parent) { - preCreate(parent); + preCreate(); createAwtDialog(parent); } --- old/src/windows/classes/sun/awt/windows/WFramePeer.java 2013-04-23 19:12:14.467833500 +0400 +++ new/src/windows/classes/sun/awt/windows/WFramePeer.java 2013-04-23 19:12:14.229819900 +0400 @@ -171,7 +171,7 @@ native void createAwtFrame(WComponentPeer parent); void create(WComponentPeer parent) { - preCreate(parent); + preCreate(); createAwtFrame(parent); } --- old/src/windows/classes/sun/awt/windows/WWindowPeer.java 2013-04-23 19:12:16.520443900 +0400 +++ new/src/windows/classes/sun/awt/windows/WWindowPeer.java 2013-04-23 19:12:16.298431200 +0400 @@ -202,15 +202,21 @@ // This method must be called for Window, Dialog, and Frame before creating // the hwnd - void preCreate(WComponentPeer parent) { + final void preCreate() { windowType = ((Window)target).getType(); } void create(WComponentPeer parent) { - preCreate(parent); + preCreate(); createAwtWindow(parent); } + @Override + final WComponentPeer getNativeParent() { + final Container parent = ((Window) target).getOwner(); + return (WComponentPeer) WToolkit.targetToPeer(parent); + } + // should be overriden in WDialogPeer protected void realShow() { super.show();