Index (Frames) | Index (No Frames) | Package | Package Tree | Tree
java.awt

Class Container

java.lang.Object
|
+--java.awt.Component
   |
   +--java.awt.Container


public class Container

extends Component

A generic window toolkit object that acts as a container for other objects. Components are tracked in a list, and new elements are at the end of the list or bottom of the stacking order.

Since:Authors:

Constructor Summary

Container()

Default constructor for subclasses.

Method Summary

java.awt.Componentadd(java.awt.Component comp)

Adds the specified component to this container at the end of the component list.
java.awt.Componentadd(java.lang.String name, java.awt.Component comp)

Adds the specified component to the container at the end of the component list.
java.awt.Componentadd(java.awt.Component comp, int index)

Adds the specified component to this container at the specified index in the component list.
voidadd(java.awt.Component comp, java.lang.Object constraints)

Adds the specified component to this container at the end of the component list.
voidadd(java.awt.Component comp, java.lang.Object constraints, int index)

Adds the specified component to this container at the specified index in the component list.
synchronized voidaddContainerListener(java.awt.event.ContainerListener l)

Adds the specified container listener to this object's list of container listeners.
voidaddImpl(java.awt.Component comp, java.lang.Object constraints, int index)

This method is called by all the add() methods to perform the actual adding of the component.
voidaddNotify()

Called when this container is added to another container to inform it to create its peer.
voidaddPropertyChangeListener(java.beans.PropertyChangeListener l)

voidaddPropertyChangeListener(java.lang.String name, java.beans.PropertyChangeListener l)

voidapplyComponentOrientation(java.awt.ComponentOrientation orientation)

Sets the ComponentOrientation property of this container and all components contained within it.
booleanareFocusTraversalKeysSet(int id)

Returns whether the Set of focus traversal keys for the given focus traversal operation has been explicitly defined for this Container.
intcountComponents()

Returns the number of components in this container.
voiddeliverEvent(java.awt.Event e)

AWT 1.0 event processor.
voiddoLayout()

Layout the components in this container.
java.awt.ComponentfindComponentAt(int x, int y)

java.awt.ComponentfindComponentAt(java.awt.Point p)

floatgetAlignmentX()

Returns the preferred alignment along the X axis.
floatgetAlignmentY()

Returns the preferred alignment along the Y axis.
java.awt.ComponentgetComponent(int n)

Returns the component at the specified index.
java.awt.ComponentgetComponentAt(int x, int y)

Returns the component located at the specified point.
java.awt.ComponentgetComponentAt(java.awt.Point p)

Returns the component located at the specified point.
intgetComponentCount()

Returns the number of components in this container.
java.awt.Component[]getComponents()

Returns an array of the components in this container.
synchronized java.awt.event.ContainerListener[]getContainerListeners()

java.util.SetgetFocusTraversalKeys(int id)

Returns the Set of focus traversal keys for a given traversal operation for this Container.
java.awt.FocusTraversalPolicygetFocusTraversalPolicy()

java.awt.InsetsgetInsets()

Returns the insets for this container, which is the space used for borders, the margin, etc.
java.awt.LayoutManagergetLayout()

Returns the current layout manager for this container.
java.util.EventListener[]getListeners(java.lang.Class listenerType)

Returns an array of all the objects currently registered as FooListeners upon this Container.
java.awt.DimensiongetMaximumSize()

Returns the maximum size of this container.
java.awt.DimensiongetMinimumSize()

Returns the minimum size of this container.
java.awt.DimensiongetPreferredSize()

Returns the preferred size of this container.
java.awt.Insetsinsets()

Returns the insets for this container, which is the space used for borders, the margin, etc.
voidinvalidate()

Invalidates this container to indicate that it (and all parent containers) need to be laid out.
booleanisAncestorOf(java.awt.Component comp)

Tests whether or not the specified component is contained within this components subtree.
booleanisFocusCycleRoot(java.awt.Container c)

booleanisFocusCycleRoot()

booleanisFocusTraversalPolicySet()

voidlayout()

Layout the components in this container.
voidlist(java.io.PrintStream out, int indent)

Writes a listing of this container to the specified stream starting at the specified indentation point.
voidlist(java.io.PrintWriter out, int indent)

Writes a listing of this container to the specified stream starting at the specified indentation point.
java.awt.Componentlocate(int x, int y)

Returns the component located at the specified point.
java.awt.DimensionminimumSize()

Returns the minimum size of this container.
voidpaint(java.awt.Graphics g)

Paints this container.
voidpaintComponents(java.awt.Graphics g)

Paints all of the components in this container.
java.lang.StringparamString()

Returns a string representing the state of this container for debugging purposes.
java.awt.DimensionpreferredSize()

Returns the preferred size of this container.
voidprint(java.awt.Graphics g)

Prints this container.
voidprintComponents(java.awt.Graphics g)

Prints all of the components in this container.
voidprocessContainerEvent(java.awt.event.ContainerEvent e)

Called when a container event occurs if container events are enabled.
voidprocessEvent(java.awt.AWTEvent e)

Processes the specified event.
voidremove(int index)

Removes the component at the specified index from this container.
voidremove(java.awt.Component comp)

Removes the specified component from this container.
voidremoveAll()

Removes all components from this container.
synchronized voidremoveContainerListener(java.awt.event.ContainerListener l)

Removes the specified container listener from this object's list of container listeners.
voidremoveNotify()

Called when this container is removed from its parent container to inform it to destroy its peer.
voidsetFocusCycleRoot(boolean focusCycleRoot)

voidsetFocusTraversalKeys(int id, java.util.Set keystrokes)

Sets the focus traversal keys for a given traversal operation for this Container.
voidsetFocusTraversalPolicy(java.awt.FocusTraversalPolicy policy)

voidsetFont(java.awt.Font f)

voidsetLayout(java.awt.LayoutManager mgr)

Sets the layout manager for this container to the specified layout manager.
voidtransferFocusBackward()

voidtransferFocusDownCycle()

voidupdate(java.awt.Graphics g)

Updates this container.
voidvalidate()

Re-lays out the components in this container.
voidvalidateTree()

Recursively validates the container tree, recomputing any invalid layouts.

Constructor Details

Container

public Container()

Default constructor for subclasses.


Method Details

add

public Component add(java.awt.Component comp)

Adds the specified component to this container at the end of the component list.

Parameters:

Returns:


add

public Component add(java.awt.Component comp, int index)

Adds the specified component to this container at the specified index in the component list.

Parameters:

Returns:

Throws:


add

public void add(java.awt.Component comp, java.lang.Object constraints)

Adds the specified component to this container at the end of the component list. The layout manager will use the specified constraints when laying out this component.

Parameters:


add

public void add(java.awt.Component comp, java.lang.Object constraints, int index)

Adds the specified component to this container at the specified index in the component list. The layout manager will use the specified constraints when layout out this component.

Parameters:

Throws:


add

public Component add(java.lang.String name, java.awt.Component comp)

Adds the specified component to the container at the end of the component list. This method should not be used. Instead, use add(Component, Object.

Parameters:

Returns:


addContainerListener

public synchronized void addContainerListener(java.awt.event.ContainerListener l)

Adds the specified container listener to this object's list of container listeners.

Parameters:


addImpl

protected void addImpl(java.awt.Component comp, java.lang.Object constraints, int index)

This method is called by all the add() methods to perform the actual adding of the component. Subclasses who wish to perform their own processing when a component is added should override this method. Any subclass doing this must call the superclass version of this method in order to ensure proper functioning of the container.

Parameters:

Throws:


addNotify

public void addNotify()

Called when this container is added to another container to inform it to create its peer. Peers for any child components will also be created.


addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener l)

Parameters:


addPropertyChangeListener

public void addPropertyChangeListener(java.lang.String name, java.beans.PropertyChangeListener l)

Parameters:


applyComponentOrientation

public void applyComponentOrientation(java.awt.ComponentOrientation orientation)

Sets the ComponentOrientation property of this container and all components contained within it.

Since:Parameters:

Throws:


areFocusTraversalKeysSet

public boolean areFocusTraversalKeysSet(int id)

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 false, this Container is inheriting the Set from an ancestor, or from the current KeyboardFocusManager.

Since:Parameters:

Throws:


countComponents

public int countComponents()

Returns the number of components in this container.

Returns:


deliverEvent

public void deliverEvent(java.awt.Event e)

AWT 1.0 event processor.

Parameters:


doLayout

public void doLayout()

Layout the components in this container.


findComponentAt

public Component findComponentAt(int x, int y)

Parameters:


findComponentAt

public Component findComponentAt(java.awt.Point p)

Parameters:


getAlignmentX

public float getAlignmentX()

Returns the preferred alignment along the X axis. This is a value between 0 and 1 where 0 represents alignment flush left and 1 means alignment flush right, and 0.5 means centered.

Returns:


getAlignmentY

public float getAlignmentY()

Returns the preferred alignment along the Y axis. This is a value between 0 and 1 where 0 represents alignment flush top and 1 means alignment flush bottom, and 0.5 means centered.

Returns:


getComponent

public Component getComponent(int n)

Returns the component at the specified index.

Parameters:

Returns:

Throws:


getComponentAt

public Component getComponentAt(int x, int y)

Returns the component located at the specified point. This is done by checking whether or not a child component claims to contain this point. The first child component that does is returned. If no child component claims the point, the container itself is returned, unless the point does not exist within this container, in which case null is returned.

Parameters:

Returns:


getComponentAt

public Component getComponentAt(java.awt.Point p)

Returns the component located at the specified point. This is done by checking whether or not a child component claims to contain this point. The first child component that does is returned. If no child component claims the point, the container itself is returned, unless the point does not exist within this container, in which case null is returned.

Parameters:

Returns:


getComponentCount

public int getComponentCount()

Returns the number of components in this container.

Returns:


getComponents

public Component[] getComponents()

Returns an array of the components in this container.

Returns:


getContainerListeners

public synchronized ContainerListener[] getContainerListeners()

Since:

getFocusTraversalKeys

public Set getFocusTraversalKeys(int id)

Returns the Set of focus traversal keys for a given traversal operation for this Container.

Since:Parameters:

Throws:


getFocusTraversalPolicy

public FocusTraversalPolicy getFocusTraversalPolicy()


getInsets

public Insets getInsets()

Returns the insets for this container, which is the space used for borders, the margin, etc.

Returns:


getLayout

public LayoutManager getLayout()

Returns the current layout manager for this container.

Returns:


getListeners

public EventListener[] getListeners(java.lang.Class listenerType)

Returns an array of all the objects currently registered as FooListeners upon this Container. FooListeners are registered using the addFooListener method.

Since:Parameters:

Throws:


getMaximumSize

public Dimension getMaximumSize()

Returns the maximum size of this container.

Returns:


getMinimumSize

public Dimension getMinimumSize()

Returns the minimum size of this container.

Returns:


getPreferredSize

public Dimension getPreferredSize()

Returns the preferred size of this container.

Returns:


insets

public Insets insets()

Returns the insets for this container, which is the space used for borders, the margin, etc.

Returns:


invalidate

public void invalidate()

Invalidates this container to indicate that it (and all parent containers) need to be laid out.


isAncestorOf

public boolean isAncestorOf(java.awt.Component comp)

Tests whether or not the specified component is contained within this components subtree.

Parameters:

Returns:


isFocusCycleRoot

public boolean isFocusCycleRoot()


isFocusCycleRoot

public boolean isFocusCycleRoot(java.awt.Container c)

Parameters:


isFocusTraversalPolicySet

public boolean isFocusTraversalPolicySet()


layout

public void layout()

Layout the components in this container.


list

public void list(java.io.PrintStream out, int indent)

Writes a listing of this container to the specified stream starting at the specified indentation point.

Parameters:


list

public void list(java.io.PrintWriter out, int indent)

Writes a listing of this container to the specified stream starting at the specified indentation point.

Parameters:


locate

public Component locate(int x, int y)

Returns the component located at the specified point. This is done by checking whether or not a child component claims to contain this point. The first child component that does is returned. If no child component claims the point, the container itself is returned, unless the point does not exist within this container, in which case null is returned.

Parameters:

Returns:


minimumSize

public Dimension minimumSize()

Returns the minimum size of this container.

Returns:


paint

public void paint(java.awt.Graphics g)

Paints this container. The implementation of this method in this class forwards to any lightweight components in this container. If this method is subclassed, this method should still be invoked as a superclass method so that lightweight components are properly drawn.

Parameters:


paintComponents

public void paintComponents(java.awt.Graphics g)

Paints all of the components in this container.

Parameters:


paramString

protected String paramString()

Returns a string representing the state of this container for debugging purposes.

Returns:


preferredSize

public Dimension preferredSize()

Returns the preferred size of this container.

Returns:


print

public void print(java.awt.Graphics g)

Prints this container. The implementation of this method in this class forwards to any lightweight components in this container. If this method is subclassed, this method should still be invoked as a superclass method so that lightweight components are properly drawn.

Parameters:


printComponents

public void printComponents(java.awt.Graphics g)

Prints all of the components in this container.

Parameters:


processContainerEvent

protected void processContainerEvent(java.awt.event.ContainerEvent e)

Called when a container event occurs if container events are enabled. This method calls any registered listeners.

Parameters:


processEvent

protected void processEvent(java.awt.AWTEvent e)

Processes the specified event. This method calls processContainerEvent() if this method is a ContainerEvent, otherwise it calls the superclass method.

Parameters:


remove

public void remove(int index)

Removes the component at the specified index from this container.

Parameters:


remove

public void remove(java.awt.Component comp)

Removes the specified component from this container.

Parameters:

Returns:


removeAll

public void removeAll()

Removes all components from this container.


removeContainerListener

public synchronized void removeContainerListener(java.awt.event.ContainerListener l)

Removes the specified container listener from this object's list of container listeners.

Parameters:


removeNotify

public void removeNotify()

Called when this container is removed from its parent container to inform it to destroy its peer. This causes the peers of all child component to be destroyed as well.


setFocusCycleRoot

public void setFocusCycleRoot(boolean focusCycleRoot)

Parameters:


setFocusTraversalKeys

public void setFocusTraversalKeys(int id, java.util.Set keystrokes)

Sets the focus traversal keys for a given traversal operation for this Container.

Since:Parameters:

Throws:


setFocusTraversalPolicy

public void setFocusTraversalPolicy(java.awt.FocusTraversalPolicy policy)

Parameters:


setFont

public void setFont(java.awt.Font f)

Parameters:


setLayout

public void setLayout(java.awt.LayoutManager mgr)

Sets the layout manager for this container to the specified layout manager.

Parameters:


transferFocusBackward

public void transferFocusBackward()


transferFocusDownCycle

public void transferFocusDownCycle()


update

public void update(java.awt.Graphics g)

Updates this container. The implementation of this method in this class forwards to any lightweight components in this container. If this method is subclassed, this method should still be invoked as a superclass method so that lightweight components are properly drawn.

Parameters:


validate

public void validate()

Re-lays out the components in this container.


validateTree

protected void validateTree()

Recursively validates the container tree, recomputing any invalid layouts.