2362N/A * Copyright (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 0N/A * published by the Free Software Foundation. Oracle designates this 0N/A * particular file as subject to the "Classpath" exception as provided 0N/A * by Oracle in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 2362N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 0N/A * or visit www.oracle.com if you need additional information or have any 0N/A * A generic Abstract Window Toolkit(AWT) container object is a component 0N/A * that can contain other AWT components. 0N/A * Components added to a container are tracked in a list. The order 0N/A * of the list will define the components' front-to-back stacking order 0N/A * within the container. If no index is specified when adding a 0N/A * component to a container, it will be added to the end of the list 0N/A * (and hence to the bottom of the stacking order). 0N/A * <b>Note</b>: For details on the focus subsystem, see 0N/A * How to Use the Focus Subsystem</a>, 0N/A * a section in <em>The Java Tutorial</em>, and the 0N/A * for more information. 0N/A * @author Arthur van Hoff 0N/A * @author Sami Shaio 0N/A * @see #add(java.awt.Component, int) 0N/A * @see #getComponent(int) 0N/A * @see LayoutManager 0N/A * The components in this container. 0N/A * @see #getComponents 0N/A * Layout manager for this container. 0N/A * Event router for lightweight components. If this container 0N/A * is native, this dispatcher takes care of forwarding and 0N/A * retargeting the events to lightweight components contained 0N/A * The focus traversal policy that will manage keyboard traversal of this 0N/A * Container's children, if this Container is a focus cycle root. If the 0N/A * value is null, this Container inherits its policy from its focus-cycle- 0N/A * root ancestor. If all such ancestors of this Container have null 0N/A * policies, then the current KeyboardFocusManager's default policy is 0N/A * used. If the value is non-null, this policy will be inherited by all 0N/A * focus-cycle-root children that have no keyboard-traversal policy of 0N/A * their own (as will, recursively, their focus-cycle-root children). 0N/A * If this Container is not a focus cycle root, the value will be 0N/A * remembered, but will not be used or inherited by this or any other 0N/A * Containers until this Container is made a focus cycle root. 0N/A * @see #setFocusTraversalPolicy 0N/A * @see #getFocusTraversalPolicy 0N/A * Indicates whether this Component is the root of a focus traversal cycle. 0N/A * Once focus enters a traversal cycle, typically it cannot leave it via 0N/A * focus traversal unless one of the up- or down-cycle keys is pressed. 0N/A * Normal traversal is limited to this Container, and all of this 0N/A * Container's descendants that are not descendants of inferior focus cycle 0N/A * @see #setFocusCycleRoot 0N/A * @see #isFocusCycleRoot 0N/A * Stores the value of focusTraversalPolicyProvider property. 0N/A * @see #setFocusTraversalPolicyProvider 0N/A // keeps track of the threads that are printing this component 0N/A // True if there is at least one thread that's printing this component 0N/A /* HierarchyListener and HierarchyBoundsListener support */ 0N/A /* Non-opaque window support -- see Window.setLayersOpaque */ 0N/A * JDK 1.1 serialVersionUID 0N/A * A constant which toggles one of the controllable behaviors 0N/A * of <code>getMouseEventTarget</code>. It is used to specify whether 0N/A * the method can return the Container on which it is originally called 0N/A * in case if none of its children are the current mouse event targets. 0N/A * @see #getMouseEventTarget(int, int, boolean, boolean, boolean) 0N/A * A constant which toggles one of the controllable behaviors 0N/A * of <code>getMouseEventTarget</code>. It is used to specify whether 0N/A * the method should search only lightweight components. 0N/A * @see #getMouseEventTarget(int, int, boolean, boolean, boolean) 0N/A * Number of HW or LW components in this container (including 0N/A * all descendant containers). 0N/A * @serialField ncomponents int 0N/A * The number of components in this container. 0N/A * This value can be null. 0N/A * @serialField component Component[] 0N/A * The components in this container. 0N/A * @serialField layoutMgr LayoutManager 0N/A * Layout manager for this container. 0N/A * @serialField dispatcher LightweightDispatcher 0N/A * Event router for lightweight components. If this container 0N/A * is native, this dispatcher takes care of forwarding and 0N/A * retargeting the events to lightweight components contained 0N/A * @serialField maxSize Dimension 0N/A * Maximum size of this Container. 0N/A * @serialField focusCycleRoot boolean 0N/A * Indicates whether this Component is the root of a focus traversal cycle. 0N/A * Once focus enters a traversal cycle, typically it cannot leave it via 0N/A * focus traversal unless one of the up- or down-cycle keys is pressed. 0N/A * Normal traversal is limited to this Container, and all of this 0N/A * Container's descendants that are not descendants of inferior focus cycle 0N/A * @serialField containerSerializedDataVersion int 0N/A * Container Serial Data Version. 0N/A * @serialField focusTraversalPolicyProvider boolean 0N/A * Stores the value of focusTraversalPolicyProvider property. 0N/A /* ensure that the necessary native libraries are loaded */ 0N/A * Initialize JNI field and method IDs for fields that may be 0N/A * Constructs a new Container. Containers can be extended directly, 0N/A * but are lightweight in this case and must be contained by a parent 0N/A * somewhere higher up in the component tree that is native. 0N/A * (such as Frame for example). 0N/A * Gets the number of components in this panel. 0N/A * Note: This method should be called under AWT tree lock. 0N/A * @return the number of components in this panel. 0N/A * @see #getComponent 0N/A * @see Component#getTreeLock() 0N/A * @deprecated As of JDK version 1.1, 0N/A * replaced by getComponentCount(). 0N/A // This method is not synchronized under AWT tree lock. 0N/A // Instead, the calling code is responsible for the 0N/A // synchronization. See 6784816 for details. 0N/A * Gets the nth component in this container. 0N/A * Note: This method should be called under AWT tree lock. 0N/A * @param n the index of the component to get. 0N/A * @return the n<sup>th</sup> component in this container. 0N/A * @exception ArrayIndexOutOfBoundsException 0N/A * if the n<sup>th</sup> value does not exist. 0N/A * @see Component#getTreeLock() 0N/A // This method is not synchronized under AWT tree lock. 0N/A // Instead, the calling code is responsible for the 0N/A // synchronization. See 6784816 for details. 0N/A * Gets all the components in this container. 0N/A * Note: This method should be called under AWT tree lock. 0N/A * @return an array of all the components in this container. 0N/A * @see Component#getTreeLock() 0N/A // This method is not synchronized under AWT tree lock. 0N/A // Instead, the calling code is responsible for the 0N/A // synchronization. See 6784816 for details. 0N/A // NOTE: This method may be called by privileged threads. 0N/A // This functionality is implemented in a package-private method 0N/A // to insure that it cannot be overridden by client subclasses. 0N/A // DO NOT INVOKE CLIENT CODE ON THIS THREAD! 0N/A * Wrapper for getComponents() method with a proper synchronization. * Determines the insets of this container, which indicate the size * of the container's border. * A <code>Frame</code> object, for example, has a top inset that * corresponds to the height of the frame's title bar. * @return the insets of this container. * @deprecated As of JDK version 1.1, * replaced by <code>getInsets()</code>. return new Insets(
0,
0,
0,
0);
* Appends the specified component to the end of this container. * This is a convenience method for {@link #addImpl}. * This method changes layout-related information, and therefore, * invalidates the component hierarchy. If the container has already been * displayed, the hierarchy must be validated thereafter in order to * display the added component. * @param comp the component to be added * @exception NullPointerException if {@code comp} is {@code null} * @see javax.swing.JComponent#revalidate() * @return the component argument * Adds the specified component to this container. * This is a convenience method for {@link #addImpl}. * This method is obsolete as of 1.1. Please use the * method <code>add(Component, Object)</code> instead. * This method changes layout-related information, and therefore, * invalidates the component hierarchy. If the container has already been * displayed, the hierarchy must be validated thereafter in order to * display the added component. * @exception NullPointerException if {@code comp} is {@code null} * @see #add(Component, Object) * Adds the specified component to this container at the given * This is a convenience method for {@link #addImpl}. * This method changes layout-related information, and therefore, * invalidates the component hierarchy. If the container has already been * displayed, the hierarchy must be validated thereafter in order to * display the added component. * @param comp the component to be added * @param index the position at which to insert the component, * or <code>-1</code> to append the component to the end * @exception NullPointerException if {@code comp} is {@code null} * @exception IllegalArgumentException if {@code index} is invalid (see * {@link #addImpl} for details) * @return the component <code>comp</code> * @see javax.swing.JComponent#revalidate() * Checks that the component * isn't supposed to be added into itself. * Checks that the component is not a Window instance. * Checks that the component comp can be added to this container * Checks : index in bounds of container's size, * comp is not one of this container's parents, * and comp is not a window. * Comp and container must be on the same GraphicsDevice. * if comp is container, all sub-components must be on * Removes component comp from this container without making unneccessary changes * and generating unneccessary events. This function intended to perform optimized * remove, for example, if newParent and current parent are the same it just changes * index without calling removeNotify. * Note: Should be called while holding treeLock * Returns whether removeNotify was invoked // We should remove component and then // add it by the newIndex without newIndex decrement if even we shift components to the left // after remove. Consult the rules below: // 2->4: 012345 -> 013425, 2->5: 012345 -> 013452 // 4->2: 012345 -> 014235 * Checks whether this container can contain component which is focus owner. * Verifies that container is enable and showing, and if it is focus cycle root * its FTP allows component to be focus owner * Checks whether or not this container has heavyweight children. * Note: Should be called while holding tree lock * @return true if there is at least one heavyweight children in a container, false otherwise * Checks whether or not this container has lightweight children. * Note: Should be called while holding tree lock * @return true if there is at least one lightweight children in a container, false otherwise * Returns closest heavyweight component to this container. If this container is heavyweight * Detects whether or not remove from current parent and adding to new parent requires call of * removeNotify on the component. Since removeNotify destroys native window this might (not) * be required. For example, if new container and old containers are the same we don't need to if (
comp.
peer ==
null) {
// Component didn't have peer - no removeNotify // Component has peer but new Container doesn't - call removeNotify // If component is lightweight non-Container or lightweight Container with all but heavyweight // children there is no need to call remove notify // If this point is reached, then the comp is either a HW or a LW container with HW descendants. // All three components have peers, check for peer change // Native containers change - check whether or not current platform supports // changing of widget hierarchy on native level without recreation. // The current implementation forbids reparenting of LW containers with HW descendants // into another native container w/o destroying the peers. Actually such an operation // is quite rare. If we ever need to save the peers, we'll have to slightly change the // addDelicately() method in order to handle such LW containers recursively, reparenting // each HW descendant independently. * Moves the specified component to the specified z-order index in * the container. The z-order determines the order that components * are painted; the component with the highest z-order paints first * and the component with the lowest z-order paints last. * Where components overlap, the component with the lower * z-order paints over the component with the higher z-order. * If the component is a child of some other container, it is * removed from that container before being added to this container. * The important difference between this method and * <code>java.awt.Container.add(Component, int)</code> is that this method * doesn't call <code>removeNotify</code> on the component while * removing it from its previous container unless necessary and when * allowed by the underlying native windowing system. This way, if the * component has the keyboard focus, it maintains the focus when * moved to the new position. * This property is guaranteed to apply only to lightweight * non-<code>Container</code> components. * This method changes layout-related information, and therefore, * invalidates the component hierarchy. * <b>Note</b>: Not all platforms support changing the z-order of * heavyweight components from one container into another without * the call to <code>removeNotify</code>. There is no way to detect * whether a platform supports this, so developers shouldn't make * @param comp the component to be moved * @param index the position in the container's list to * insert the component, where <code>getComponentCount()</code> * @exception NullPointerException if <code>comp</code> is * @exception IllegalArgumentException if <code>comp</code> is one of the * @exception IllegalArgumentException if <code>index</code> is not in * the range <code>[0, getComponentCount()]</code> for moving * between containers, or not in the range * <code>[0, getComponentCount()-1]</code> for moving inside * @exception IllegalArgumentException if adding a container to itself * @exception IllegalArgumentException if adding a <code>Window</code> * @see #getComponentZOrder(java.awt.Component) // Store parent because remove will clear it // If the oldZindex == -1, the component gets inserted, // rather than it changes its z-order. // The new 'index' cannot be == -1. // It gets checked at the checkAdding() method. // Therefore both oldZIndex and index denote // some existing positions at this point and // this is actually a Z-order changing. * Traverses the tree of components and reparents children heavyweight component * to new heavyweight parent. // If components is lightweight check if it is container // If it is container it might contain heavyweight children we need to reparent // Q: Need to update NativeInLightFixer? * Reparents child component peer to this container peer. * Container must be heavyweight. // If component is lightweight container we need to reparent all its explicit heavyweight children // Traverse component's tree till depth-first until encountering heavyweight component * Adds component to this container. Tries to minimize side effects of this adding - * doesn't call remove notify if it is not required. // Check if moving between containers //index == -1 means add to the end. if (
comp.
peer ==
null) {
// Remove notify was called or it didn't have peer - create new one }
else {
// Both container and child have peers, it means child peer should be reparented. // In both cases we need to reparent native widgets. // Native container changed - need to reparent native widgets // If component is heavyweight and one of the containers is lightweight // the location of the component should be fixed. /* Notify the layout manager of the added component. */ // If component is focus owner or parent container of focus owner check that after reparenting // focus owner moved out if new container prohibit this kind of focus owner. * Returns the z-order index of the component inside the container. * The higher a component is in the z-order hierarchy, the lower * its index. The component with the lowest z-order index is * painted last, above all other child components. * @param comp the component being queried * @return the z-order index of the component; otherwise * returns -1 if the component is <code>null</code> * or doesn't belong to the container * @see #setComponentZOrder(java.awt.Component, int) // Quick check - container should be immediate parent of the component * Adds the specified component to the end of this container. * Also notifies the layout manager to add the component to * this container's layout using the specified constraints object. * This is a convenience method for {@link #addImpl}. * This method changes layout-related information, and therefore, * invalidates the component hierarchy. If the container has already been * displayed, the hierarchy must be validated thereafter in order to * display the added component. * @param comp the component to be added * @param constraints an object expressing * layout contraints for this component * @exception NullPointerException if {@code comp} is {@code null} * @see javax.swing.JComponent#revalidate() * Adds the specified component to this container with the specified * constraints at the specified index. Also notifies the layout * manager to add the component to the this container's layout using * the specified constraints object. * This is a convenience method for {@link #addImpl}. * This method changes layout-related information, and therefore, * invalidates the component hierarchy. If the container has already been * displayed, the hierarchy must be validated thereafter in order to * display the added component. * @param comp the component to be added * @param constraints an object expressing layout contraints for this * @param index the position in the container's list at which to insert * the component; <code>-1</code> means insert at the end * @exception NullPointerException if {@code comp} is {@code null} * @exception IllegalArgumentException if {@code index} is invalid (see * {@link #addImpl} for details) * @see javax.swing.JComponent#revalidate() * Adds the specified component to this container at the specified * index. This method also notifies the layout manager to add * the component to this container's layout using the specified * constraints object via the <code>addLayoutComponent</code> * defined by the particular layout manager being used. For * example, the <code>BorderLayout</code> class defines five * constraints: <code>BorderLayout.NORTH</code>, * <code>BorderLayout.SOUTH</code>, <code>BorderLayout.EAST</code>, * <code>BorderLayout.WEST</code>, and <code>BorderLayout.CENTER</code>. * The <code>GridBagLayout</code> class requires a * <code>GridBagConstraints</code> object. Failure to pass * the correct type of constraints object results in an * <code>IllegalArgumentException</code>. * If the current layout manager implements {@code LayoutManager2}, then * {@link LayoutManager2#addLayoutComponent(Component,Object)} is invoked on * it. If the current layout manager does not implement * {@code LayoutManager2}, and constraints is a {@code String}, then * {@link LayoutManager#addLayoutComponent(String,Component)} is invoked on it. * If the component is not an ancestor of this container and has a non-null * parent, it is removed from its current parent before it is added to this * This is the method to override if a program needs to track * every add request to a container as all other add methods defer * to this one. An overriding method should * usually include a call to the superclass's version of the method: * <code>super.addImpl(comp, constraints, index)</code> * This method changes layout-related information, and therefore, * invalidates the component hierarchy. If the container has already been * displayed, the hierarchy must be validated thereafter in order to * display the added component. * @param comp the component to be added * @param constraints an object expressing layout constraints * @param index the position in the container's list at which to * insert the component, where <code>-1</code> * means append to the end * @exception IllegalArgumentException if {@code index} is invalid; * if {@code comp} is a child of this container, the valid * range is {@code [-1, getComponentCount()-1]}; if component is * not a child of this container, the valid range is * {@code [-1, getComponentCount()]} * @exception IllegalArgumentException if {@code comp} is an ancestor of * @exception IllegalArgumentException if adding a window to a container * @exception NullPointerException if {@code comp} is {@code null} * @see #add(Component, int) * @see #add(Component, java.lang.Object) /* Check for correct arguments: index in bounds, * comp cannot be one of this container's parents, * and comp cannot be a window. * comp and container must be on the same GraphicsDevice. * if comp is container, all sub-components must be on "illegal component position");
/* Reparent the component and tidy up the tree's state. */ //index == -1 means add to the end. /* Notify the layout manager of the added component. */ * Checks that all Components that this Container contains are on * the same GraphicsDevice as this Container. If not, throws an * IllegalArgumentException. * Removes the component, specified by <code>index</code>, * This method also notifies the layout manager to remove the * component from this container's layout via the * <code>removeLayoutComponent</code> method. * This method changes layout-related information, and therefore, * invalidates the component hierarchy. If the container has already been * displayed, the hierarchy must be validated thereafter in order to * @param index the index of the component to be removed * @throws ArrayIndexOutOfBoundsException if {@code index} is not in * range {@code [0, getComponentCount()-1]} * @see #getComponentCount * Removes the specified component from this container. * This method also notifies the layout manager to remove the * component from this container's layout via the * <code>removeLayoutComponent</code> method. * This method changes layout-related information, and therefore, * invalidates the component hierarchy. If the container has already been * displayed, the hierarchy must be validated thereafter in order to * @param comp the component to be removed * @throws NullPointerException if {@code comp} is {@code null} * Removes all the components from this container. * This method also notifies the layout manager to remove the * components from this container's layout via the * <code>removeLayoutComponent</code> method. * This method changes layout-related information, and therefore, * invalidates the component hierarchy. If the container has already been * displayed, the hierarchy must be validated thereafter in order to // Should only be called while holding tree lock // Verify listeningChildren is correct eventLog.
fine(
"Assertion (listeningChildren == sum) failed");
// Verify listeningBoundsChildren is correct eventLog.
fine(
"Assertion (listeningBoundsChildren == sum) failed");
// Should only be called while holding tree lock // Should only be called while holding tree lock // Should only be called while holding tree lock // Should only be called while holding tree lock // Verify descendantsCount is correct log.
fine(
"Assertion (descendantsCount == sum) failed");
* Gets the layout manager for this container. * Sets the layout manager for this container. * This method changes layout-related information, and therefore, * invalidates the component hierarchy. * @param mgr the specified layout manager * Causes this container to lay out its components. Most programs * should not call this method directly, but should invoke * the <code>validate</code> method instead. * @see LayoutManager#layoutContainer * @deprecated As of JDK version 1.1, * replaced by <code>doLayout()</code>. * Indicates if this container is a <i>validate root</i>. * Layout-related changes, such as bounds of the validate root descendants, * do not affect the layout of the validate root parent. This peculiarity * enables the {@code invalidate()} method to stop invalidating the * component hierarchy when the method encounters a validate root. However, * to preserve backward compatibility this new optimized behavior is * enabled only when the {@code java.awt.smartInvalidate} system property * value is set to {@code true}. * If a component hierarchy contains validate roots and the new optimized * {@code invalidate()} behavior is enabled, the {@code validate()} method * must be invoked on the validate root of a previously invalidated * component to restore the validity of the hierarchy later. Otherwise, * calling the {@code validate()} method on the top-level container (such * as a {@code Frame} object) should be used to restore the validity of the * The {@code Window} class and the {@code Applet} class are the validate * roots in AWT. Swing introduces more validate roots. * @return whether this container is a validate root * @see java.awt.Component#invalidate * @see javax.swing.JComponent#isValidateRoot * @see javax.swing.JComponent#revalidate // Don't lazy-read because every app uses invalidate() * Invalidates the parent of the container unless the container * Invalidates the container. * If the {@code LayoutManager} installed on this container is an instance * of the {@code LayoutManager2} interface, then * the {@link LayoutManager2#invalidateLayout(Container)} method is invoked * on it supplying this {@code Container} as the argument. * Afterwards this method marks this container invalid, and invalidates its * ancestors. See the {@link Component#invalidate} method for more details. * Validates this container and all of its subcomponents. * Validating a container means laying out its subcomponents. * Layout-related changes, such as setting the bounds of a component, or * adding a component to the container, invalidate the container * automatically. Note that the ancestors of the container may be * invalidated also (see {@link Component#invalidate} for details.) * Therefore, to restore the validity of the hierarchy, the {@code * validate()} method should be invoked on the top-most invalid * container of the hierarchy. * Validating the container may be a quite time-consuming operation. For * performance reasons a developer may postpone the validation of the * hierarchy till a set of layout-related operations completes, e.g. after * adding all the children to the container. * If this {@code Container} is not valid, this method invokes * the {@code validateTree} method and marks this {@code Container} * as valid. Otherwise, no action is performed. * @see #add(java.awt.Component) * @see Container#isValidateRoot * @see javax.swing.JComponent#revalidate() // Avoid updating cursor if this is an internal call. // See validateUnconditionally() for details. * Indicates whether valid containers should also traverse their * children and call the validateTree() method on them. * Synchronization: TreeLock. * The field is allowed to be static as long as the TreeLock itself is * @see #validateUnconditionally() * Unconditionally validate the component hierarchy. * 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>. * Recursively descends the container tree and invalidates all * Sets the font of this container. * This method changes layout-related information, and therefore, * invalidates the component hierarchy. * @param f The font to become this container's font. * Returns the preferred size of this container. If the preferred size has * not been set explicitly by {@link Component#setPreferredSize(Dimension)} * and this {@code Container} has a {@code non-null} {@link LayoutManager}, * then {@link LayoutManager#preferredLayoutSize(Container)} * is used to calculate the preferred size. * <p>Note: some implementations may cache the value returned from the * {@code LayoutManager}. Implementations that cache need not invoke * {@code preferredLayoutSize} on the {@code LayoutManager} every time * this method is invoked, rather the {@code LayoutManager} will only * be queried after the {@code Container} becomes invalid. * @return an instance of <code>Dimension</code> that represents * the preferred size of this container. * @see LayoutManager#preferredLayoutSize(Container) * @see Component#getPreferredSize * @deprecated As of JDK version 1.1, * replaced by <code>getPreferredSize()</code>. /* Avoid grabbing the lock if a reasonable cached size value * Returns the minimum size of this container. If the minimum size has * not been set explicitly by {@link Component#setMinimumSize(Dimension)} * and this {@code Container} has a {@code non-null} {@link LayoutManager}, * then {@link LayoutManager#minimumLayoutSize(Container)} * is used to calculate the minimum size. * <p>Note: some implementations may cache the value returned from the * {@code LayoutManager}. Implementations that cache need not invoke * {@code minimumLayoutSize} on the {@code LayoutManager} every time * this method is invoked, rather the {@code LayoutManager} will only * be queried after the {@code Container} becomes invalid. * @return an instance of <code>Dimension</code> that represents * the minimum size of this container. * @see LayoutManager#minimumLayoutSize(Container) * @see Component#getMinimumSize * @deprecated As of JDK version 1.1, * replaced by <code>getMinimumSize()</code>. /* Avoid grabbing the lock if a reasonable cached size value * Returns the maximum size of this container. If the maximum size has * not been set explicitly by {@link Component#setMaximumSize(Dimension)} * and the {@link LayoutManager} installed on this {@code Container} * is an instance of {@link LayoutManager2}, then * {@link LayoutManager2#maximumLayoutSize(Container)} * is used to calculate the maximum size. * <p>Note: some implementations may cache the value returned from the * {@code LayoutManager2}. Implementations that cache need not invoke * {@code maximumLayoutSize} on the {@code LayoutManager2} every time * this method is invoked, rather the {@code LayoutManager2} will only * be queried after the {@code Container} becomes invalid. * @return an instance of <code>Dimension</code> that represents * the maximum size of this container. * @see LayoutManager2#maximumLayoutSize(Container) * @see Component#getMaximumSize /* Avoid grabbing the lock if a reasonable cached size value * Returns the alignment along the x axis. This specifies how * the component would like to be aligned relative to other * components. The value should be a number between 0 and 1 * where 0 represents alignment along the origin, 1 is aligned * the furthest away from the origin, 0.5 is centered, etc. * Returns the alignment along the y axis. This specifies how * the component would like to be aligned relative to other * components. The value should be a number between 0 and 1 * where 0 represents alignment along the origin, 1 is aligned * the furthest away from the origin, 0.5 is centered, etc. * Paints the container. This forwards the paint to any lightweight * components that are children of this container. If this method is * reimplemented, super.paint(g) should be called so that lightweight * components are properly rendered. If a child component is entirely * clipped by the current clipping setting in g, paint() will not be * forwarded to that child. * @param g the specified Graphics window * @see Component#update(Graphics) // The container is showing on screen and // this paint() is not called from print(). // Paint self and forward the paint to lightweight subcomponents. // super.paint(); -- Don't bother, since it's a NOP. * Updates the container. This forwards the update to any lightweight * components that are children of this container. If this method is * reimplemented, super.update(g) should be called so that lightweight * components are properly rendered. If a child component is entirely * clipped by the current clipping setting in g, update() will not be * forwarded to that child. * @param g the specified Graphics window * @see Component#update(Graphics) * Prints the container. This forwards the print to any lightweight * components that are children of this container. If this method is * reimplemented, super.print(g) should be called so that lightweight * components are properly rendered. If a child component is entirely * clipped by the current clipping setting in g, print() will not be * forwarded to that child. * @param g the specified Graphics window * @see Component#update(Graphics) super.
print(g);
// By default, Component.print() calls paint() * Paints each of the components in this container. * @param g the graphics context. * @see Component#paintAll * Simulates the peer callbacks into java.awt for printing of * lightweight Containers. * @param g the graphics context to use for printing. * @see Component#printAll * Prints all the heavyweight subcomponents. * Prints each of the components in this container. * @param g the graphics context. * @see Component#printAll * Simulates the peer callbacks into java.awt for printing of * lightweight Containers. * @param g the graphics context to use for printing. * @see Component#printAll * Prints all the heavyweight subcomponents. * Adds the specified container listener to receive container events * If l is null, no exception is thrown and no action is performed. * >AWT Threading Issues</a> for details on AWT's threading model. * @param l the container listener * @see #removeContainerListener * @see #getContainerListeners * Removes the specified container listener so it no longer receives * container events from this container. * If l is null, no exception is thrown and no action is performed. * >AWT Threading Issues</a> for details on AWT's threading model. * @param l the container listener * @see #addContainerListener * @see #getContainerListeners * Returns an array of all the container listeners * registered on this container. * @return all of this container's <code>ContainerListener</code>s * or an empty array if no container * listeners are currently registered * @see #addContainerListener * @see #removeContainerListener * Returns an array of all the objects currently registered * as <code><em>Foo</em>Listener</code>s * upon this <code>Container</code>. * <code><em>Foo</em>Listener</code>s are registered using the * <code>add<em>Foo</em>Listener</code> method. * You can specify the <code>listenerType</code> argument * with a class literal, such as * <code><em>Foo</em>Listener.class</code>. * For example, you can query a * <code>Container</code> <code>c</code> * for its container listeners with the following code: * <pre>ContainerListener[] cls = (ContainerListener[])(c.getListeners(ContainerListener.class));</pre> * If no such listeners exist, this method returns an empty array. * @param listenerType the type of listeners requested; this parameter * should specify an interface that descends from * <code>java.util.EventListener</code> * @return an array of all objects registered as * <code><em>Foo</em>Listener</code>s on this container, * or an empty array if no such listeners have been added * @exception ClassCastException if <code>listenerType</code> * doesn't specify a class or interface that implements * <code>java.util.EventListener</code> * @exception NullPointerException if {@code listenerType} is {@code null} * @see #getContainerListeners // REMIND: remove when filtering is done at lower level * Processes events on this container. If the event is a * <code>ContainerEvent</code>, it invokes the * <code>processContainerEvent</code> method, else it invokes * its superclass's <code>processEvent</code>. * <p>Note that if the event parameter is <code>null</code> * the behavior is unspecified and may result in an * Processes container events occurring on this container by * dispatching them to any registered ContainerListener objects. * NOTE: This method will not be called unless container events * are enabled for this component; this happens when one of the * <li>A ContainerListener object is registered via * <code>addContainerListener</code> * <li>Container events are enabled via <code>enableEvents</code> * <p>Note that if the event parameter is <code>null</code> * the behavior is unspecified and may result in an * @param e the container event * @see Component#enableEvents * Dispatches an event to this component or one of its sub components. * Create ANCESTOR_RESIZED and ANCESTOR_MOVED events in response to * COMPONENT_RESIZED and COMPONENT_MOVED events. We have to do this * here instead of in processComponentEvent because ComponentEvents * may not be enabled for this Container. // event was sent to a lightweight component. The // native-produced event sent to the native container // must be properly disposed of by the peer, so it // gets forwarded. If the native host has been removed // as a result of the sending the lightweight event, // the peer reference will be null. * Dispatches an event to this component, without trying to forward * it to any subcomponents * Fetchs the top-most (deepest) lightweight component that is interested * in receiving mouse events. * Fetches the top-most (deepest) component to receive SunDropTargetEvents. * A private version of getMouseEventTarget which has two additional * controllable behaviors. This method searches for the top-most * descendant of this container that contains the given coordinates * and is accepted by the given filter. The search will be constrained to * lightweight descendants if the last argument is <code>false</code>. * @param filter EventTargetFilter instance to determine whether the * given component is a valid target for this event. * @param searchHeavyweights if <code>false</code>, the method * will bypass heavyweight components during the search. * A private version of getMouseEventTarget which has three additional * controllable behaviors. This method searches for the top-most * descendant of this container that contains the given coordinates * and is accepted by the given filter. The search will be constrained to * descendants of only lightweight children or only heavyweight children * of this container depending on searchHeavyweightChildren. The search will * be constrained to only lightweight descendants of the searched children * of this container if searchHeavyweightDescendants is <code>false</code>. * @param filter EventTargetFilter instance to determine whether the * selected component is a valid target for this event. * @param searchHeavyweightChildren if <code>true</code>, the method * will bypass immediate lightweight children during the search. * If <code>false</code>, the methods will bypass immediate * heavyweight children during the search. * @param searchHeavyweightDescendants if <code>false</code>, the method * will bypass heavyweight descendants which are not immediate * children during the search. If <code>true</code>, the method * will traverse both lightweight and heavyweight descendants during // found a component that intersects the point, see if there // is a deeper possibility. // there isn't a deeper target, but this component // didn't find a child target, return this component if it's * This is called by lightweight components that want the containing * windowed parent to enable some kind of events on their behalf. * This is needed for events that are normally only dispatched to * windows to be accepted so that they can be forwarded downward to * the lightweight component that has enabled them. // this container is lightweight.... continue sending it // This is a native container, so it needs to host // one of it's children. If this function is called before // a peer has been created we don't yet have a dispatcher // because it has not yet been determined if this instance * @deprecated As of JDK version 1.1, * replaced by <code>dispatchEvent(AWTEvent e)</code> * Locates the component that contains the x,y position. The * top-most child component is returned in the case where there * is overlap in the components. This is determined by finding * the component closest to the index 0 that claims to contain * the given point via Component.contains(), except that Components * which have native peers take precedence over those which do not * (i.e., lightweight Components). * @param x the <i>x</i> coordinate * @param y the <i>y</i> coordinate * @return null if the component does not contain the position. * If there is no child component at the requested point and the * point is within the bounds of the container the container itself * is returned; otherwise the top-most child is returned. * @see Component#contains * @deprecated As of JDK version 1.1, * replaced by <code>getComponentAt(int, int)</code>. // Two passes: see comment in sun.awt.SunGraphicsCallback * Gets the component that contains the specified point. * @return returns the component that contains the point, * or <code>null</code> if the component does * @see Component#contains * Returns the position of the mouse pointer in this <code>Container</code>'s * coordinate space if the <code>Container</code> is under the mouse pointer, * otherwise returns <code>null</code>. * This method is similar to {@link Component#getMousePosition()} with the exception * that it can take the <code>Container</code>'s children into account. * If <code>allowChildren</code> is <code>false</code>, this method will return * a non-null value only if the mouse pointer is above the <code>Container</code> * directly, not above the part obscured by children. * If <code>allowChildren</code> is <code>true</code>, this method returns * a non-null value if the mouse pointer is above <code>Container</code> or any * @exception HeadlessException if GraphicsEnvironment.isHeadless() returns true * @param allowChildren true if children should be taken into account * @see Component#getMousePosition * @return mouse coordinates relative to this <code>Component</code>, or null * Locates the visible child component that contains the specified * position. The top-most child component is returned in the case * where there is overlap in the components. If the containing child * component is a Container, this method will continue searching for * the deepest nested child component. Components which are not * visible are ignored during the search.<p> * The findComponentAt method is different from getComponentAt in * that getComponentAt only searches the Container's immediate * children; if the containing component is a Container, * findComponentAt will search that child to find a nested component. * @param x the <i>x</i> coordinate * @param y the <i>y</i> coordinate * @return null if the component does not contain the position. * If there is no child component at the requested point and the * point is within the bounds of the container the container itself * @see Component#contains * Private version of findComponentAt which has a controllable * behavior. Setting 'ignoreEnabled' to 'false' bypasses disabled * Components during the search. This behavior is used by the * lightweight cursor support in sun.awt.GlobalCursorManager. * The cursor code calls this function directly via native code. * The addition of this feature is temporary, pending the * adoption of new, public API which exports this feature. // Two passes: see comment in sun.awt.SunGraphicsCallback * Locates the visible child component that contains the specified * point. The top-most child component is returned in the case * where there is overlap in the components. If the containing child * component is a Container, this method will continue searching for * the deepest nested child component. Components which are not * visible are ignored during the search.<p> * The findComponentAt method is different from getComponentAt in * that getComponentAt only searches the Container's immediate * children; if the containing component is a Container, * findComponentAt will search that child to find a nested component. * @return null if the component does not contain the position. * If there is no child component at the requested point and the * point is within the bounds of the container the container itself * @throws NullPointerException if {@code p} is {@code null} * @see Component#contains * 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 // 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. // We shouldn't use iterator because of the Swing menu // implementation specifics: // the menu is being assigned as a child to JLayeredPane // instead of particular component so always affect // collection of component if menu is becoming shown or hidden. * Makes this Container undisplayable by removing its connection * to its native screen resource. Making a container undisplayable * will cause all of its children to be made undisplayable. * This method is called by the toolkit internally and should * not be called directly by programs. * @see Component#isDisplayable // We shouldn't use iterator because of the Swing menu // implementation specifics: // the menu is being assigned as a child to JLayeredPane // instead of particular component so always affect // collection of component if menu is becoming shown or hidden. // We want to suppress focus change on disposal // of the focused component. But because of focus // is asynchronous, we should suppress focus change // on every component in case it receives native focus // in the process of disposal. // If some of the children had focus before disposal then it still has. // Auto-transfer focus to the next (or previous) component if auto-transfer * Checks if the component is contained in the component hierarchy of * @return <code>true</code> if it is an ancestor; * <code>false</code> otherwise. * The following code was added to support modal JInternalFrames * Unfortunately this code has to be added here so that we can get access to * some private AWT classes like SequencedEvent. * The native container of the LW component has this field set * to tell it that it should block Mouse events for all LW * children except for the modal component. * In the case of nested Modal components, we store the previous * modal component in the new modal components value of modalComp; // Store the app context on which this component is being shown. // Event dispatch thread of this app context will be sleeping until // we wake it by any event from hideAndDisposeHandler(). // keep the KeyEvents from being dispatched // until the focus has been transfered // We have two mechanisms for blocking: 1. If we're on the // EventDispatchThread, start a new event pump. 2. If we're // on any other thread, call wait() on the treelock. // Wake up event dispatch thread on which the dialog was /* End of JOptionPane support code */ * Returns a string representing the state of this <code>Container</code>. * This method is intended to be used only for debugging purposes, and the * content and format of the returned string may vary between * implementations. The returned string may be empty but may not be * @return the parameter string of this container * Prints a listing of this container to the specified output * stream. The listing starts at the specified indentation. * The immediate children of the container are printed with * an indentation of <code>indent+1</code>. The children * of those children are printed at <code>indent+2</code> * @param out a print stream * @param indent the number of spaces to indent * @throws NullPointerException if {@code out} is {@code null} * @see Component#list(java.io.PrintStream, int) * Prints out a list, starting at the specified indentation, * to the specified print writer. * The immediate children of the container are printed with * an indentation of <code>indent+1</code>. The children * of those children are printed at <code>indent+2</code> * @param out a print writer * @param indent the number of spaces to indent * @throws NullPointerException if {@code out} is {@code null} * @see Component#list(java.io.PrintWriter, int) * Sets the focus traversal keys for a given traversal operation for this * The default values for a Container's focus traversal keys are * implementation-dependent. Sun recommends that all implementations for a * particular native platform use the same default values. The * recommendations for Windows and Unix are listed below. These * recommendations are used in the Sun AWT implementations. * <table border=1 summary="Recommended default values for a Container's focus traversal keys"> * <td>KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS</td> * <td>Normal forward keyboard traversal</td> * <td>TAB on KEY_PRESSED, CTRL-TAB on KEY_PRESSED</td> * <td>KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS</td> * <td>Normal reverse keyboard traversal</td> * <td>SHIFT-TAB on KEY_PRESSED, CTRL-SHIFT-TAB on KEY_PRESSED</td> * <td>KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS</td> * <td>Go up one focus traversal cycle</td> * <td>KeyboardFocusManager.DOWN_CYCLE_TRAVERSAL_KEYS<td> * <td>Go down one focus traversal cycle</td> * To disable a traversal key, use an empty Set; Collections.EMPTY_SET is * Using the AWTKeyStroke API, client code can specify on which of two * specific KeyEvents, KEY_PRESSED or KEY_RELEASED, the focus traversal * operation will occur. Regardless of which KeyEvent is specified, * however, all KeyEvents related to the focus traversal key, including the * associated KEY_TYPED event, will be consumed, and will not be dispatched * to any Container. It is a runtime error to specify a KEY_TYPED event as * mapping to a focus traversal operation, or to map the same event to * multiple default focus traversal operations. * If a value of null is specified for the Set, this Container inherits the * Set from its parent. If all ancestors of this Container have null * specified for the Set, then the current KeyboardFocusManager's default * @param id one of KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, * KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, * KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS, or * KeyboardFocusManager.DOWN_CYCLE_TRAVERSAL_KEYS * @param keystrokes the Set of AWTKeyStroke for the specified operation * @see #getFocusTraversalKeys * @see KeyboardFocusManager#FORWARD_TRAVERSAL_KEYS * @see KeyboardFocusManager#BACKWARD_TRAVERSAL_KEYS * @see KeyboardFocusManager#UP_CYCLE_TRAVERSAL_KEYS * @see KeyboardFocusManager#DOWN_CYCLE_TRAVERSAL_KEYS * @throws IllegalArgumentException if id is not one of * KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, * KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, * KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS, or * KeyboardFocusManager.DOWN_CYCLE_TRAVERSAL_KEYS, or if keystrokes * contains null, or if any Object in keystrokes is not an * AWTKeyStroke, or if any keystroke represents a KEY_TYPED event, * or if any keystroke already maps to another focus traversal * operation for this Container // Don't call super.setFocusTraversalKey. The Component parameter check // does not allow DOWN_CYCLE_TRAVERSAL_KEYS, but we do. * Returns the Set of focus traversal keys for a given traversal operation * for this Container. (See * <code>setFocusTraversalKeys</code> for a full description of each key.) * If a Set of traversal keys has not been explicitly defined for this * Container, then this Container's parent's Set is returned. If no Set * has been explicitly defined for any of this Container's ancestors, then * the current KeyboardFocusManager's default Set is returned. * @param id one of KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, * KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, * KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS, or * KeyboardFocusManager.DOWN_CYCLE_TRAVERSAL_KEYS * @return the Set of AWTKeyStrokes for the specified operation. The Set * will be unmodifiable, and may be empty. null will never be * @see #setFocusTraversalKeys * @see KeyboardFocusManager#FORWARD_TRAVERSAL_KEYS * @see KeyboardFocusManager#BACKWARD_TRAVERSAL_KEYS * @see KeyboardFocusManager#UP_CYCLE_TRAVERSAL_KEYS * @see KeyboardFocusManager#DOWN_CYCLE_TRAVERSAL_KEYS * @throws IllegalArgumentException if id is not one of * KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, * KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, * KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS, or * KeyboardFocusManager.DOWN_CYCLE_TRAVERSAL_KEYS // Don't call super.getFocusTraversalKey. The Component parameter check // does not allow DOWN_CYCLE_TRAVERSAL_KEY, but we do. * Returns whether the Set of focus traversal keys for the given focus * traversal operation has been explicitly defined for this Container. If * this method returns <code>false</code>, this Container is inheriting the * Set from an ancestor, or from the current KeyboardFocusManager. * @param id one of KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, * KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, * KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS, or * KeyboardFocusManager.DOWN_CYCLE_TRAVERSAL_KEYS * @return <code>true</code> if the the Set of focus traversal keys for the * given focus traversal operation has been explicitly defined for * this Component; <code>false</code> otherwise. * @throws IllegalArgumentException if id is not one of * KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, * KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, * KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS, or * KeyboardFocusManager.DOWN_CYCLE_TRAVERSAL_KEYS * Returns whether the specified Container is the focus cycle root of this * Container's focus traversal cycle. Each focus traversal cycle has only * a single focus cycle root and each Container which is not a focus cycle * root belongs to only a single focus traversal cycle. Containers which * are focus cycle roots belong to two cycles: one rooted at the Container * itself, and one rooted at the Container's nearest focus-cycle-root * ancestor. This method will return <code>true</code> for both such * Containers in this case. * @param container the Container to be tested * @return <code>true</code> if the specified Container is a focus-cycle- * root of this Container; <code>false</code> otherwise * @see #isFocusCycleRoot() // I potentially have two roots, myself and my root parent // If I am the current root, then use me // If none of my parents are roots, then use me // If my root parent is the current root, then use my root parent // If neither I nor my root parent is the current root, then // use my root parent (a guess) * Check if this component is the child of this container or its children. * Note: this function acquires treeLock * Note: this function traverses children tree only in one Window. * @param comp a component in test, must not be null // This synchronized should always be the second in a pair // (tree lock, KeyboardFocusManager.class) * Sets the focus traversal policy that will manage keyboard traversal of * this Container's children, if this Container is a focus cycle root. If * the argument is null, this Container inherits its policy from its focus- * cycle-root ancestor. If the argument is non-null, this policy will be * inherited by all focus-cycle-root children that have no keyboard- * traversal policy of their own (as will, recursively, their focus-cycle- * If this Container is not a focus cycle root, the policy will be * remembered, but will not be used or inherited by this or any other * Containers until this Container is made a focus cycle root. * @param policy the new focus traversal policy for this Container * @see #getFocusTraversalPolicy * @see #setFocusCycleRoot * Returns the focus traversal policy that will manage keyboard traversal * of this Container's children, or null if this Container is not a focus * cycle root. If no traversal policy has been explicitly set for this * Container, then this Container's focus-cycle-root ancestor's policy is * @return this Container's focus traversal policy, or null if this * Container is not a focus cycle root. * @see #setFocusTraversalPolicy * @see #setFocusCycleRoot * Returns whether the focus traversal policy has been explicitly set for * this Container. If this method returns <code>false</code>, this * Container will inherit its focus traversal policy from an ancestor. * @return <code>true</code> if the focus traversal policy has been * explicitly set for this Container; <code>false</code> otherwise. * Sets whether this Container is the root of a focus traversal cycle. Once * focus enters a traversal cycle, typically it cannot leave it via focus * traversal unless one of the up- or down-cycle keys is pressed. Normal * traversal is limited to this Container, and all of this Container's * descendants that are not descendants of inferior focus cycle roots. Note * that a FocusTraversalPolicy may bend these restrictions, however. For * example, ContainerOrderFocusTraversalPolicy supports implicit down-cycle * The alternative way to specify the traversal order of this Container's * children is to make this Container a * @param focusCycleRoot indicates whether this Container is the root of a * @see #isFocusCycleRoot() * @see #setFocusTraversalPolicy * @see #getFocusTraversalPolicy * @see ContainerOrderFocusTraversalPolicy * @see #setFocusTraversalPolicyProvider * Returns whether this Container is the root of a focus traversal cycle. * Once focus enters a traversal cycle, typically it cannot leave it via * focus traversal unless one of the up- or down-cycle keys is pressed. * Normal traversal is limited to this Container, and all of this * Container's descendants that are not descendants of inferior focus * cycle roots. Note that a FocusTraversalPolicy may bend these * restrictions, however. For example, ContainerOrderFocusTraversalPolicy * supports implicit down-cycle traversal. * @return whether this Container is the root of a focus traversal cycle * @see #setFocusCycleRoot * @see #setFocusTraversalPolicy * @see #getFocusTraversalPolicy * @see ContainerOrderFocusTraversalPolicy * Sets whether this container will be used to provide focus * traversal policy. Container with this property as * <code>true</code> will be used to acquire focus traversal policy * instead of closest focus cycle root ancestor. * @param provider indicates whether this container will be used to * provide focus traversal policy * @see #setFocusTraversalPolicy * @see #getFocusTraversalPolicy * @see #isFocusTraversalPolicyProvider * Returns whether this container provides focus traversal * policy. If this property is set to <code>true</code> then when * keyboard focus manager searches container hierarchy for focus * traversal policy and encounters this container before any other * container with this property as true or focus cycle roots then * its focus traversal policy will be used instead of focus cycle * @see #setFocusTraversalPolicy * @see #getFocusTraversalPolicy * @see #setFocusCycleRoot * @see #setFocusTraversalPolicyProvider * @return <code>true</code> if this container provides focus traversal * policy, <code>false</code> otherwise * Transfers the focus down one focus traversal cycle. If this Container is * a focus cycle root, then the focus owner is set to this Container's * default Component to focus, and the current focus cycle root is set to * this Container. If this Container is not a focus cycle root, then no * focus traversal operation occurs. * @see Component#requestFocus() * @see #setFocusCycleRoot * Sets the <code>ComponentOrientation</code> property of this container * and all components contained within it. * This method changes layout-related information, and therefore, * invalidates the component hierarchy. * @param o the new component orientation of this container and * the components contained within it. * @exception NullPointerException if <code>orientation</code> is null. * @see Component#setComponentOrientation * @see Component#getComponentOrientation * Adds a PropertyChangeListener to the listener list. The listener is * registered for all bound properties of this class, including the * <li>this Container's font ("font")</li> * <li>this Container's background color ("background")</li> * <li>this Container's foreground color ("foreground")</li> * <li>this Container's focusability ("focusable")</li> * <li>this Container's focus traversal keys enabled state * ("focusTraversalKeysEnabled")</li> * <li>this Container's Set of FORWARD_TRAVERSAL_KEYS * ("forwardFocusTraversalKeys")</li> * <li>this Container's Set of BACKWARD_TRAVERSAL_KEYS * ("backwardFocusTraversalKeys")</li> * <li>this Container's Set of UP_CYCLE_TRAVERSAL_KEYS * ("upCycleFocusTraversalKeys")</li> * <li>this Container's Set of DOWN_CYCLE_TRAVERSAL_KEYS * ("downCycleFocusTraversalKeys")</li> * <li>this Container's focus traversal policy ("focusTraversalPolicy") * <li>this Container's focus-cycle-root state ("focusCycleRoot")</li> * Note that if this Container is inheriting a bound property, then no * event will be fired in response to a change in the inherited property. * If listener is null, no exception is thrown and no action is performed. * @param listener the PropertyChangeListener to be added * @see Component#removePropertyChangeListener * @see #addPropertyChangeListener(java.lang.String,java.beans.PropertyChangeListener) * Adds a PropertyChangeListener to the listener list for a specific * property. The specified property may be user-defined, or one of the * <li>this Container's font ("font")</li> * <li>this Container's background color ("background")</li> * <li>this Container's foreground color ("foreground")</li> * <li>this Container's focusability ("focusable")</li> * <li>this Container's focus traversal keys enabled state * ("focusTraversalKeysEnabled")</li> * <li>this Container's Set of FORWARD_TRAVERSAL_KEYS * ("forwardFocusTraversalKeys")</li> * <li>this Container's Set of BACKWARD_TRAVERSAL_KEYS * ("backwardFocusTraversalKeys")</li> * <li>this Container's Set of UP_CYCLE_TRAVERSAL_KEYS * ("upCycleFocusTraversalKeys")</li> * <li>this Container's Set of DOWN_CYCLE_TRAVERSAL_KEYS * ("downCycleFocusTraversalKeys")</li> * <li>this Container's focus traversal policy ("focusTraversalPolicy") * <li>this Container's focus-cycle-root state ("focusCycleRoot")</li> * <li>this Container's focus-traversal-policy-provider state("focusTraversalPolicyProvider")</li> * <li>this Container's focus-traversal-policy-provider state("focusTraversalPolicyProvider")</li> * Note that if this Container is inheriting a bound property, then no * event will be fired in response to a change in the inherited property. * If listener is null, no exception is thrown and no action is performed. * @param propertyName one of the property names listed above * @param listener the PropertyChangeListener to be added * @see #addPropertyChangeListener(java.beans.PropertyChangeListener) * @see Component#removePropertyChangeListener // Serialization support. A Container is responsible for restoring the // parent fields of its component children. * Container Serial Data Version. * Serializes this <code>Container</code> to the specified * <code>ObjectOutputStream</code>. * <li>Writes default serializable fields to the stream.</li> * <li>Writes a list of serializable ContainerListener(s) as optional * data. The non-serializable ContainerListner(s) are detected and * no attempt is made to serialize them.</li> * <li>Write this Container's FocusTraversalPolicy if and only if it * is Serializable; otherwise, <code>null</code> is written.</li> * @param s the <code>ObjectOutputStream</code> to write * @serialData <code>null</code> terminated sequence of 0 or more pairs; * the pair consists of a <code>String</code> and <code>Object</code>; * the <code>String</code> indicates the type of object and * is one of the following: * <code>containerListenerK</code> indicating an * <code>ContainerListener</code> object; * the <code>Container</code>'s <code>FocusTraversalPolicy</code>, * @see AWTEventMulticaster#save(java.io.ObjectOutputStream, java.lang.String, java.util.EventListener) * @see Container#containerListenerK * @see #readObject(ObjectInputStream) * Deserializes this <code>Container</code> from the specified * <code>ObjectInputStream</code>. * <li>Reads default serializable fields from the stream.</li> * <li>Reads a list of serializable ContainerListener(s) as optional * data. If the list is null, no Listeners are installed.</li> * <li>Reads this Container's FocusTraversalPolicy, which may be null, * @param s the <code>ObjectInputStream</code> to read * @see #addContainerListener * @see #writeObject(ObjectOutputStream) // Old stream. Doesn't contain maxSize among Component's fields. // skip value for unrecognized key // JDK 1.1/1.2/1.3 instances will not have this optional data. // e.eof will be true to indicate that there is no more data // available for this object. If e.eof is not true, throw the // exception as it might have been caused by reasons unrelated to * --- Accessibility Support --- * Inner class of Container used to provide default support for * accessibility. This class is not meant to be used directly by * application developers, but is instead meant only to be * subclassed by container developers. * The class used to obtain the accessible role for this object, * as well as implementing many of the methods in the * AccessibleContainer interface. * JDK1.3 serialVersionUID * Returns the number of accessible children in the object. If all * of the children of this object implement <code>Accessible</code>, * then this method should return the number of children of this object. * @return the number of accessible children in the object * Returns the nth <code>Accessible</code> child of the object. * @param i zero-based index of child * @return the nth <code>Accessible</code> child of the object * Returns the <code>Accessible</code> child, if one exists, * contained at the local coordinate <code>Point</code>. * @param p the point defining the top-left corner of the * <code>Accessible</code>, given in the coordinate space * @return the <code>Accessible</code>, if it exists, * at the specified location; else <code>null</code> * Fire <code>PropertyChange</code> listener, if one is registered, * when children are added or removed. * Adds a PropertyChangeListener to the listener list. * @param listener the PropertyChangeListener to be added }
// inner class AccessibleAWTContainer * Returns the <code>Accessible</code> child contained at the local * coordinate <code>Point</code>, if one exists. Otherwise * returns <code>null</code>. * @param p the point defining the top-left corner of the * <code>Accessible</code>, given in the coordinate space * @return the <code>Accessible</code> at the specified location, * if it exists; otherwise <code>null</code> * Returns the number of accessible children in the object. If all * of the children of this object implement <code>Accessible</code>, * then this method should return the number of children of this object. * @return the number of accessible children in the object * Returns the nth <code>Accessible</code> child of the object. * @param i zero-based index of child * @return the nth <code>Accessible</code> child of the object // ************************** MIXING CODE ******************************* "Peer does not exist while invoking the increaseComponentCount() method" "Peer does not exist while invoking the decreaseComponentCount() method" * This method is overriden to handle opaque children in non-opaque // An invalid container with not-null layout should be ignored // by the mixing code, the container will be validated later // and the mixing code will be executed later. // An invalid container with not-null layout should be ignored // by the mixing code, the container will be validated later // and the mixing code will be executed later. * Checks if the container and its direct lightweight containers are * Consider the heavyweight container hides or shows the HW descendants * automatically. Therefore we care of LW containers' visibility only. * This method MUST be invoked under the TreeLock. // ****************** END OF MIXING CODE ******************************** * Class to manage the dispatching of MouseEvents to the lightweight descendants * and SunDropTargetEvents to both lightweight and heavyweight descendants * contained by a native container. * NOTE: the class name is not appropriate anymore, but we cannot change it * because we must keep serialization compatibility. * @author Timothy Prinzing * JDK 1.1 serialVersionUID * Our own mouse event for when we're dragged over from another hw * Clean up any resources allocated when dispatcher was created; * should be called from Container.removeNotify //System.out.println("Disposing lw dispatcher"); * Enables events to subcomponents. * Dispatches an event to a sub-component if necessary, and * returns whether or not the event was forwarded to a * Fix for BugTraq Id 4389284. * Dispatch SunDropTargetEvents regardless of eventMask value. * Do not update cursor on dispatching SunDropTargetEvents. /* This method effectively returns whether or not a mouse button was down * just BEFORE the event happened. A better method name might be * wasAMouseButtonDownBeforeThisEvent(). /* modifiers now as just before event */ * This method attempts to distribute a mouse event to a lightweight * component. It tries to avoid doing any unnecessary probes down * into the component tree to minimize the overhead of determining * where to route the event, since mouse movement events tend to * come in large and frequent amounts. // 4508327 : MOUSE_CLICKED should only go to the recipient of // the accompanying MOUSE_PRESSED, so don't reset mouseEventTarget on a // 4508327: MOUSE_CLICKED should never be dispatched to a Component // other than that which received the MOUSE_PRESSED event. If the // mouse is now over a different Component, don't dispatch the event. // The previous fix for a similar problem was associated with bug // This may send it somewhere that doesn't have MouseWheelEvents // enabled. In this case, Component.dispatchEventImpl() will // retarget the event to a parent that DOES have the events enabled. //Consuming of wheel events is implemented in "retargetMouseEvent". * Fix for BugTraq ID 4395290. * It is possible that SunDropTargetEvent's Point is outside of the * native container bounds. In this case we truncate coordinates. * Generates enter/exit events as mouse moves over lw components * @param targetOver Target mouse is over (including native container) * @param e Mouse event in native container // This can happen if a lightweight component which initiated the // drag has an associated drop target. MOUSE_ENTERED comes when the // mouse is in the native container already. To propagate this event // properly we should null out targetLastEntered. // any event but an exit or drag means we're in the native container // consume native exit event if we generate one // consume native enter event if we generate one * Listens to global mouse drag events so even drags originating * from other heavyweight containers will generate enter/exit * events in this container //System.out.println("Adding AWTEventListener"); //System.out.println("Removing AWTEventListener"); * (Implementation of AWTEventListener) * Listen for drag events posted in other hw components so we can * track enter/exit regardless of where a drag originated // only interested in drags from other hw components // component may have disappeared since drag event posted // (i.e. Swing hierarchical menus) // check if srcComponent is in any modal blocked window // create an internal 'dragged-over' event indicating // we are being dragged over from another hw component // translate coordinates to this native container //System.out.println("Track event: " + me); // feed the 'dragged-over' event directly to the enter/exit // code (not a real event so don't pass it to dispatchEvent) * Sends a mouse event to the current mouse event recipient using * the given event (sent to the windowed host) as a srcEvent. If * the mouse event target is still in the component tree, the * coordinates of the event are translated to those of the target. * If the target has been removed, we don't bother to send the return;
// mouse is over another hw component or target is disabled // avoid recursively calling LightweightDispatcher... //An exception for wheel bubbling to the native system. //In "processMouseEvent" total event consuming for wheel events is skipped. //Protection from bubbling of Java-accepted wheel events. // --- member variables ------------------------------- * The windowed container that might be hosting events for * This variable is not used, but kept for serialization compatibility * The current subcomponent being hosted by this windowed * component that has events being forwarded to it. If this * is null, there are currently no events being forwarded to * The last component entered * Is the mouse over the native container * This variable is not used, but kept for serialization compatibility * The event mask for contained lightweight components. Lightweight * components need a windowed container to host window-related * events. This separate mask indicates events that have been * requested by contained lightweight components without effecting * the mask of the windowed component itself. * The kind of events routed to lightweight components from windowed