java::awt::Container Class Reference

Inheritance diagram for java::awt::Container:

Inheritance graph
java::awt::Paneljava::awt::Windowjava::awt::Componentjava::lang::Objectjava::lang::Interfacejava::lang::Syncjava::awt::event::ComponentSourcejava::awt::event::FocusSourcejava::awt::event::HierarchySourcejava::awt::event::KeySourcejava::awt::event::MouseSourcejava::awt::event::PaintSourcejava::util::PropertyChangeSourcejava::awt::event::ContainerSourcejava::lang::Lockjava::lang::ScopeAdapterjava::awt::image::ImageObserverjava::util::EventSourcejava::awt::Dialogjava::awt::Frame
[legend]
Collaboration diagram for java::awt::Container:

Collaboration graph
java::awt::Componentjava::lang::Objectjava::lang::Interfacejava::lang::ObjectRefjava::lang::Syncjava::awt::event::ComponentSourcejava::awt::event::FocusSourcejava::awt::event::HierarchySourcejava::awt::event::KeySourcejava::awt::event::MouseSourcejava::awt::event::PaintSourcejava::util::PropertyChangeSourcejava::awt::event::ContainerSourcejava::lang::Lockjava::lang::ScopeAdapterjava::lang::Comparablejava::awt::image::ImageObserverjava::util::EventSourcejava::util::Collectionjava::util::LinkedListjava::util::AbstractSequentialListjava::util::AbstractListjava::util::AbstractCollectionjava::util::List
[legend]

List of all members.


Detailed Description

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).

Version:
1.239, 02/26/03
Author:
Arthur van Hoff

Sami Shaio

See also:
add(java.awt.Component, int)

getComponent(int)

LayoutManager

Since:
JDK1.0

Public Member Functions

virtual jint getComponentCount () const
 Gets the number of components in this panel.
virtual Ref< ComponentgetComponent (jint n) const
 Gets the nth component in this container.
virtual Array< Ref
< Component > > 
getComponents () const
 Gets all the components in this container.
virtual void paint (Graphics &g)
 Paints this container.
virtual Insets getInsets () const
 Determines the insets of this container, which indicate the size of the container's border.
virtual void add (const String &name, const Ref< Component > &comp)
 Adds the specified component to this container with the specified constraints at the specified index.
virtual void add (const Ref< Component > &comp, const ObjectRef &constraints=0, jint index=-1)
 Adds the specified component to this container with the specified constraints at the specified index.
virtual void remove (jint index)
 Removes the component, specified by index, from this container.
virtual void remove (const Ref< Component > &comp)
 Removes the specified component from this container.
virtual void removeAll ()
 Removes all the components from this container.
virtual Ref
< LayoutManager
getLayout () const
 Gets the layout manager for this container.
virtual void setLayout (const Ref< LayoutManager > &mgr)
 Sets the layout manager for this container.
virtual void doLayout ()
 Causes this container to lay out its components.
virtual void invalidate ()
 Invalidates the container.
virtual void validate ()
 Validates this container and all of its subcomponents.
virtual void setFont (const Ref< Font > &f)
 Sets the font of this container.
virtual Dimension getPreferredSize () const
 Returns the preferred size of this container.
virtual Dimension getMinimumSize () const
 Returns the minimum size of this container.
virtual Dimension getMaximumSize () const
 Returns the maximum size of this container.
virtual jfloat getAlignmentX () const
 Returns the alignment along the x axis.
virtual jfloat getAlignmentY () const
 Returns the alignment along the y axis.
virtual void paintComponents (Graphics &g)
 Paints each of the components in this container.
virtual void printComponents (Graphics &g)
 Prints each of the components in this container.
virtual Ref< ComponentgetComponentAt (jint x, jint y)
 Locates the component that contains the x,y position.
virtual Ref< ComponentgetComponentAt (const Point &p)
 Gets the component that contains the specified point.
virtual Ref< ComponentfindComponentAt (jint x, jint y, jboolean ignoreEnabled=true)
 Locates the visible child component that contains the specified position.
virtual Ref< ComponentfindComponentAt (const Point &p, jboolean ignoreEnabled=true)
 Locates the visible child component that contains the specified point.
virtual void addNotify ()
 Makes this Container displayable by connecting it to a native screen resource.
virtual void removeNotify ()
 Makes this Container undisplayable by removing its connection to its native screen resource.
virtual void dispatchEvent (AWTEvent &e)
 Dispatches an event to this component or one of its sub components.
virtual jboolean isAncestorOf (const Component &c) const
 Checks if the component is contained in the component hierarchy of this container.
virtual Ref< ListgetListeners (const Class &type) const
 Returns an array of all the objects currently registered as FooListeners upon this Container.
virtual jboolean eventEnabled (const AWTEvent &e) const
virtual void processEvent (const AWTEvent &e)
 Processes events on this container.
virtual String toString () const
 Returns a string representation of this component and its values.
virtual void applyComponentOrientation (const ComponentOrientation &o)
 Sets the ComponentOrientation property of this container and all components contained within it.
virtual jboolean isFocusCycleRoot (const Ref< Container > &container=0) const
 Returns whether the specified Container is the focus cycle root of this Container's focus traversal cycle.
virtual void setFocusCycleRoot (jboolean focusCycleRoot)
 Sets whether this Container is the root of a focus traversal cycle.
void setBorder (const Ref< border::Border > &border)
 Sets the border of this component.
Ref< border::Border > getBorder () const
 Returns the border of this component or null if no border is currently set.

Member Function Documentation

virtual jint java::awt::Container::getComponentCount (  )  const [virtual]

Gets the number of components in this panel.

Returns:
the number of components in this panel.
See also:
getComponent
Since:
JDK1.1

virtual Ref<Component> java::awt::Container::getComponent ( jint  n  )  const [virtual]

Gets the nth component in this container.

Parameters:
n the index of the component to get.
Returns:
the nth component in this container.
Exceptions:
ArrayIndexOutOfBoundsException if the nth value does not exist.

virtual Array<Ref<Component> > java::awt::Container::getComponents (  )  const [virtual]

Gets all the components in this container.

Returns:
an array of all the components in this container.

virtual void java::awt::Container::paint ( Graphics g  )  [virtual]

Paints this container.

Parameters:
g the graphics context to use for painting
Since:
JDK1.0

Reimplemented from java::awt::Component.

virtual Insets java::awt::Container::getInsets (  )  const [virtual]

Determines the insets of this container, which indicate the size of the container's border.

A Frame object, for example, has a top inset that corresponds to the height of the frame's title bar.

Returns:
the insets of this container.
See also:
Insets

LayoutManager

Since:
JDK1.1

virtual void java::awt::Container::add ( const String name,
const Ref< Component > &  comp 
) [virtual]

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 addImpl.

Note: If a component has been added to a container that has been displayed, validate must be called on that container to display the new component. If multiple components are being added, you can improve efficiency by calling validate only once, after all the components have been added.

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
See also:
addImpl

validate

javax.swing.JComponent::revalidate()

remove

LayoutManager

virtual void java::awt::Container::add ( const Ref< Component > &  comp,
const ObjectRef constraints = 0,
jint  index = -1 
) [virtual]

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 addImpl.

Note: If a component has been added to a container that has been displayed, validate must be called on that container to display the new component. If multiple components are being added, you can improve efficiency by calling validate only once, after all the components have been added.

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
See also:
addImpl

validate

javax.swing.JComponent::revalidate()

remove

LayoutManager

virtual void java::awt::Container::remove ( jint  index  )  [virtual]

Removes the component, specified by index, from this container.

Parameters:
index the index of the component to be removed.
See also:
add
Since:
JDK1.1

virtual void java::awt::Container::remove ( const Ref< Component > &  comp  )  [virtual]

Removes the specified component from this container.

Parameters:
comp the component to be removed
See also:
add

virtual void java::awt::Container::removeAll (  )  [virtual]

Removes all the components from this container.

See also:
add

remove

virtual Ref<LayoutManager> java::awt::Container::getLayout (  )  const [virtual]

Gets the layout manager for this container.

See also:
doLayout

setLayout

virtual void java::awt::Container::setLayout ( const Ref< LayoutManager > &  mgr  )  [virtual]

Sets the layout manager for this container.

Parameters:
mgr the specified layout manager
See also:
doLayout

getLayout

virtual void java::awt::Container::doLayout (  )  [virtual]

Causes this container to lay out its components.

Most programs should not call this method directly, but should invoke the validate method instead.

See also:
LayoutManager::layoutContainer

setLayout

validate

Since:
JDK1.1

Reimplemented from java::awt::Component.

virtual void java::awt::Container::invalidate (  )  [virtual]

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.

See also:
validate

layout

LayoutManager

Reimplemented from java::awt::Component.

virtual void java::awt::Container::validate (  )  [virtual]

Validates this container and all of its subcomponents.

The validate method is used to cause a container to lay out its subcomponents again. It should be invoked when this container's subcomponents are modified (added to or removed from the container, or layout-related information changed) after the container has been displayed.

See also:
add(java.awt.Component)

Component::invalidate

javax.swing.JComponent::revalidate()

Reimplemented from java::awt::Component.

virtual void java::awt::Container::setFont ( const Ref< Font > &  f  )  [virtual]

Sets the font of this container.

Parameters:
f The font to become this container's font.
See also:
Component::getFont
Since:
JDK1.0

Reimplemented from java::awt::Component.

virtual Dimension java::awt::Container::getPreferredSize (  )  const [virtual]

Returns the preferred size of this container.

Returns:
an instance of Dimension that represents the preferred size of this container.
See also:
getMinimumSize

getLayout

LayoutManager::preferredLayoutSize(Container)

Component::getPreferredSize

Reimplemented from java::awt::Component.

virtual Dimension java::awt::Container::getMinimumSize (  )  const [virtual]

Returns the minimum size of this container.

Returns:
an instance of Dimension that represents the minimum size of this container.
See also:
getPreferredSize

getLayout

LayoutManager::minimumLayoutSize(Container)

Component::getMinimumSize

Since:
JDK1.1

Reimplemented from java::awt::Component.

virtual Dimension java::awt::Container::getMaximumSize (  )  const [virtual]

Returns the maximum size of this container.

See also:
getPreferredSize

Reimplemented from java::awt::Component.

virtual jfloat java::awt::Container::getAlignmentX (  )  const [virtual]

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.

Reimplemented from java::awt::Component.

virtual jfloat java::awt::Container::getAlignmentY (  )  const [virtual]

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.

Reimplemented from java::awt::Component.

virtual void java::awt::Container::paintComponents ( Graphics g  )  [virtual]

Paints each of the components in this container.

Parameters:
g the graphics context.
See also:
Component::paint

Component::paintAll

virtual void java::awt::Container::printComponents ( Graphics g  )  [virtual]

Prints each of the components in this container.

Parameters:
g the graphics context.
See also:
Component::print

Component::printAll

virtual Ref<Component> java::awt::Container::getComponentAt ( jint  x,
jint  y 
) [virtual]

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).

Parameters:
x the x coordinate
y the y coordinate
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.
See also:
Component::contains
Since:
JDK1.1

virtual Ref<Component> java::awt::Container::getComponentAt ( const Point p  )  [virtual]

Gets the component that contains the specified point.

Parameters:
p the point.
Returns:
returns the component that contains the point, or null if the component does not contain the point.
See also:
Component::contains
Since:
JDK1.1

virtual Ref<Component> java::awt::Container::findComponentAt ( jint  x,
jint  y,
jboolean  ignoreEnabled = true 
) [virtual]

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.

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.

Parameters:
x the x coordinate
y the y coordinate
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.
See also:
Component::contains

getComponentAt

Since:
1.2

virtual Ref<Component> java::awt::Container::findComponentAt ( const Point p,
jboolean  ignoreEnabled = true 
) [virtual]

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.

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.

Parameters:
p the point.
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.
See also:
Component::contains

getComponentAt

Since:
1.2

virtual void java::awt::Container::addNotify (  )  [virtual]

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 also:
Component::isDisplayable

removeNotify

Reimplemented from java::awt::Component.

virtual void java::awt::Container::removeNotify (  )  [virtual]

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 also:
Component::isDisplayable

addNotify

Reimplemented from java::awt::Component.

virtual void java::awt::Container::dispatchEvent ( AWTEvent e  )  [virtual]

Dispatches an event to this component or one of its sub components.

Calls processEvent before returning for 1.1-style events which have been enabled for the Component.

Parameters:
e the event

Reimplemented from java::awt::Component.

Reimplemented in java::awt::Window.

virtual jboolean java::awt::Container::isAncestorOf ( const Component c  )  const [virtual]

Checks if the component is contained in the component hierarchy of this container.

Parameters:
c the component
Returns:
true if it is an ancestor; false otherwise.
Since:
JDK1.1

virtual Ref<List> java::awt::Container::getListeners ( const Class type  )  const [virtual]

Returns an array of all the objects currently registered as FooListeners upon this Container.

FooListeners are registered using the addFooListener method.

You can specify the listenerType argument with a class literal, such as FooListener.class. For example, you can query a Container c for its container listeners with the following code:

ContainerListener[] cls = (ContainerListener[])(c.getListeners(ContainerListener.class));

If no such listeners exist, this method returns an empty array.

Parameters:
listenerType the type of listeners requested; this parameter should specify an interface that descends from java.util.EventListener
Returns:
an array of all objects registered as FooListeners on this container, or an empty array if no such listeners have been added
Exceptions:
ClassCastException if listenerType doesn't specify a class or interface that implements java.util.EventListener
See also:
getContainerListeners
Since:
1.3

Reimplemented from java::awt::Component.

Reimplemented in java::awt::Window.

virtual jboolean java::awt::Container::eventEnabled ( const AWTEvent e  )  const [virtual]

Reimplemented from java::awt::Component.

Reimplemented in java::awt::Window.

virtual void java::awt::Container::processEvent ( const AWTEvent e  )  [virtual]

Processes events on this container.

If the event is a ContainerEvent, it invokes the processContainerEvent method, else it invokes its superclass's processEvent.

Note that if the event parameter is null the behavior is unspecified and may result in an exception.

Parameters:
e the event

Reimplemented from java::awt::Component.

Reimplemented in java::awt::Window.

virtual String java::awt::Container::toString (  )  const [virtual]

Returns a string representation of this component and its values.

Returns:
a string representation of this component
Since:
JDK1.0

Reimplemented from java::awt::Component.

Reimplemented in java::awt::Dialog, java::awt::Frame, and java::awt::Window.

virtual void java::awt::Container::applyComponentOrientation ( const ComponentOrientation o  )  [virtual]

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

Parameters:
o the new component orientation of this container and the components contained within it.
Exceptions:
NullPointerException if orientation is null.
See also:
Component::setComponentOrientation

Component::getComponentOrientation

Since:
1.4

Reimplemented from java::awt::Component.

virtual jboolean java::awt::Container::isFocusCycleRoot ( const Ref< Container > &  container = 0  )  const [virtual]

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 true for both such Containers in this case.

Parameters:
container the Container to be tested
Returns:
true if the specified Container is a focus-cycle- root of this Container; false otherwise
See also:
isFocusCycleRoot()
Since:
1.4

Reimplemented from java::awt::Component.

virtual void java::awt::Container::setFocusCycleRoot ( jboolean  focusCycleRoot  )  [virtual]

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 traversal.

Parameters:
focusCycleRoot indicates whether this Container is the root of a focus traversal cycle
See also:
isFocusCycleRoot()

setFocusTraversalPolicy

getFocusTraversalPolicy

ContainerOrderFocusTraversalPolicy

Since:
1.4 bound: true

void java::awt::Container::setBorder ( const Ref< border::Border > &  border  ) 

Sets the border of this component.

The Border object is responsible for defining the insets for the component (overriding any insets set directly on the component) and for optionally rendering any border decorations within the bounds of those insets. Borders should be used (rather than insets) for creating both decorative and non-decorative (such as margins and padding) regions for a swing component. Compound borders can be used to nest multiple borders within a single component.

This is a bound property.

Parameters:
border the border to be rendered for this component
See also:
Border

CompoundBorder bound: true preferred: true attribute: visualUpdate true description: The component's border.

Ref<border::Border> java::awt::Container::getBorder (  )  const

Returns the border of this component or null if no border is currently set.

Returns:
the border object for this component
See also:
setBorder


The documentation for this class was generated from the following file:
Generated on Fri May 16 11:55:57 2008 for CrossPlatformJavaLikeC++API by  doxygen 1.5.3