/** * Traverses the tree of components and reparents children heavyweight component * to new heavyweight parent. * @since 1.5 */ private void reparentTraverse(ContainerPeer parentPeer, Container child) { checkTreeLock(); for (int i = 0; i < child.getComponentCount(); i++) { Component comp = child.getComponent(i); if (comp.isLightweight()) { // If components is lightweight check if it is container // If it is container it might contain heavyweight children we need to reparent if (comp instanceof Container) { reparentTraverse(parentPeer, (Container)comp); } } else { // Q: Need to update NativeInLightFixer? comp.getPeer().reparent(parentPeer); } } }
/** * Reparents child component peer to this container peer. * Container must be heavyweight. * @since 1.5 */ private void reparentChild(Component comp) { checkTreeLock(); if (comp == null) { return; } if (comp.isLightweight()) { // If component is lightweight container we need to reparent all its explicit heavyweight children if (comp instanceof Container) { // Traverse component's tree till depth-first until encountering heavyweight component reparentTraverse((ContainerPeer)getPeer(), (Container)comp); } } else { comp.getPeer().reparent((ContainerPeer)getPeer()); } }
/** * Unconditionally validate the component hierarchy. */ final void validateUnconditionally() { boolean updateCur = false; synchronized (getTreeLock()) { descendUnconditionallyWhenValidating = true; validate(); if (peer instanceof ContainerPeer) { updateCur = isVisible(); } descendUnconditionallyWhenValidating = false; } if (updateCur) { updateCursorImmediately(); } }
/** * Traverses the tree of components and reparents children heavyweight component * to new heavyweight parent. * @since 1.5 */ @SuppressWarnings("deprecation") private void reparentTraverse(ContainerPeer parentPeer, Container child) { checkTreeLock(); for (int i = 0; i < child.getComponentCount(); i++) { Component comp = child.getComponent(i); if (comp.isLightweight()) { // If components is lightweight check if it is container // If it is container it might contain heavyweight children we need to reparent if (comp instanceof Container) { reparentTraverse(parentPeer, (Container)comp); } } else { // Q: Need to update NativeInLightFixer? comp.peer.reparent(parentPeer); } } }
/** * Reparents child component peer to this container peer. * Container must be heavyweight. * @since 1.5 */ @SuppressWarnings("deprecation") private void reparentChild(Component comp) { checkTreeLock(); if (comp == null) { return; } if (comp.isLightweight()) { // If component is lightweight container we need to reparent all its explicit heavyweight children if (comp instanceof Container) { // Traverse component's tree till depth-first until encountering heavyweight component reparentTraverse((ContainerPeer)peer, (Container)comp); } } else { comp.peer.reparent((ContainerPeer) peer); } }
/** * Recursively descends the container tree and recomputes the * layout for any subtrees marked as needing it (those marked as * invalid). Synchronization should be provided by the method * that calls this one: <code>validate</code>. * * @see #doLayout * @see #validate */ protected void validateTree() { if (!valid) { if (peer instanceof ContainerPeer) { ((ContainerPeer)peer).beginLayout(); } doLayout(); Component component[] = this.component; for (int i = 0 ; i < ncomponents ; ++i) { Component comp = component[i]; if ( (comp instanceof Container) && !(comp instanceof Window) && !comp.valid) { ((Container)comp).validateTree(); } else { comp.validate(); } } if (peer instanceof ContainerPeer) { ((ContainerPeer)peer).endLayout(); } } valid = true; }
/** * Makes this Container displayable by connecting it to * a native screen resource. Making a container displayable will * cause all of its children to be made displayable. * This method is called internally by the toolkit and should * not be called directly by programs. * @see Component#isDisplayable * @see #removeNotify */ public void addNotify() { synchronized (getTreeLock()) { // addNotify() on the children may cause proxy event enabling // on this instance, so we first call super.addNotify() and // possibly create an lightweight event dispatcher before calling // addNotify() on the children which may be lightweight. super.addNotify(); if (! (peer instanceof LightweightPeer)) { dispatcher = new LightweightDispatcher(this); } int ncomponents = this.ncomponents; Component component[] = this.component; for (int i = 0 ; i < ncomponents ; i++) { component[i].addNotify(); } // Update stacking order if native platform allows ContainerPeer cpeer = (ContainerPeer)peer; if (cpeer.isRestackSupported()) { cpeer.restack(); } } }