A generic Abstract Window Toolkit(AWT) container object is a component
that can contain other AWT components.
Components added to a container are tracked in a list. The order
of the list will define the components' front-to-back stacking order
within the container. If no index is specified when adding a
component to a container, it will be added to the end of the list
(and hence to the bottom of the stacking order).
Recursively descends the container tree and recomputes the
layout for any subtrees marked as needing it (those marked as
invalid).
Container
protected Container()
Constructs a new Container. Containers can be extended directly,
but are lightweight in this case and must be contained by a parent
somewhere higher up in the component tree that is native.
(such as Frame for example).
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.
Parameters:
comp - the component to be added
constraints - an object expressing
layout contraints for this component
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.
Parameters:
comp - the component to be added
constraints - an object expressing layout contraints for this
index - the position in the container's list at which to insert
the component. -1 means insert at the end.
component
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.
This is the method to override if a program needs to track
every add request to a container. An overriding method should
usually include a call to the superclass's version of the method:
super.addImpl(comp, constraints, index)
Parameters:
comp - the component to be added.
constraints - an object expressing layout contraints
for this component.
index - the position in the container's list at which to
insert the component, where -1
means insert at the end.
Invalidates the container. The container and all parents
above it are marked as needing to be laid out. This method can
be called often, so it needs to execute quickly.
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: validate.
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.
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.
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.
Processes events on this container. If the event is a ContainerEvent,
it invokes the processContainerEvent method, else it invokes its
superclass's processEvent.
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
following occurs:
a) A ContainerListener object is registered via addContainerListener()
b) Container events are enabled via enableEvents()
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().
Parameters:
x - the x coordinate
y - the y Returns:
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.
Notifies the container to create a peer. It will also
notify the components contained in this container.
This method should be called by Container.add,
and not by user code directly.
Notifies this container and all of its subcomponents to remove
their peers.
This method should be invoked by the container's
remove method, and not directly by user code.