java.awt
Class Container

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
All Implemented Interfaces:
java.awt.image.ImageObserver
Direct Known Subclasses:
Panel, Window

public abstract class Container
extends Component

A generic Abstract Window Toolkit(AWT) container object is a component that can contain other AWT components.


Field Summary
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Method Summary
 Component add(Component comp)
          Adds the specified component to this container.
 Component add(Component comp, int pos)
          Adds the specified component to this container at the given position.
 Component add(String name, Component comp)
          Adds the specified component to this container.
 void addNotify()
          Notifies the container to create a peer.
 int countComponents()
          Returns the number of components in this panel.
 void deliverEvent(Event e)
          Delivers an event.
 Component getComponent(int n)
          Gets the nth component in this container.
 Component[] getComponents()
          Gets all the components in this container.
 LayoutManager getLayout()
          Gets the layout manager for this container.
 Insets insets()
          Returns the insets of the container.
 void layout()
          Does a layout on this Container.
 void list(PrintStream out, int indent)
          Prints out a list, starting at the specified indention, to the specified out stream.
 Component locate(int x, int y)
          Locates the component that contains the x,y position.
 Dimension minimumSize()
          Returns the minimum size of this container.
 void paintComponents(Graphics g)
          Paints the components in this container.
protected  String paramString()
          Returns the parameter String of this Container.
 Dimension preferredSize()
          Returns the preferred size of this container.
 void printComponents(Graphics g)
          Prints the components in this container.
 void remove(Component comp)
          Removes the specified component from this container.
 void removeAll()
          Removes all the components from this container.
 void removeNotify()
          Notifies the container to remove its peer.
 void setLayout(LayoutManager mgr)
          Sets the layout manager for this container.
 void validate()
          Validates this Container and all of the components contained within it.
 
Methods inherited from class java.awt.Component
action, bounds, checkImage, checkImage, createImage, createImage, disable, enable, enable, getBackground, getColorModel, getFont, getFontMetrics, getForeground, getGraphics, getParent, getPeer, getToolkit, gotFocus, handleEvent, hide, imageUpdate, inside, invalidate, isEnabled, isShowing, isValid, isVisible, keyDown, keyUp, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paint, paintAll, postEvent, prepareImage, prepareImage, print, printAll, repaint, repaint, repaint, repaint, requestFocus, reshape, resize, resize, setBackground, setFont, setForeground, show, show, size, toString, update
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

countComponents

public int countComponents()
Returns the number of components in this panel.

See Also:
getComponent(int)

getComponent

public Component getComponent(int n)
Gets the nth component in this container.

Parameters:
n - the number of the component to get
Throws:
ArrayIndexOutOfBoundsException - If the nth value does not exist.

getComponents

public Component[] getComponents()
Gets all the components in this container.


insets

public Insets insets()
Returns the insets of the container. The insets indicate the size of the border of the container. A Frame, for example, will have a top inset that corresponds to the height of the Frame's title bar.

See Also:
LayoutManager

add

public Component add(Component comp)
Adds the specified component to this container.

Parameters:
comp - the component to be added

add

public Component add(Component comp,
                     int pos)
Adds the specified component to this container at the given position.

Parameters:
comp - the component to be added
pos - the position at which to insert the component. -1 means insert at the end.
See Also:
remove(java.awt.Component)

add

public Component add(String name,
                     Component comp)
Adds the specified component to this container. The component is also added to the layout manager of this container using the name specified .

Parameters:
name - the component name
comp - the component to be added
See Also:
remove(java.awt.Component), LayoutManager

remove

public void remove(Component comp)
Removes the specified component from this container.

Parameters:
comp - the component to be removed
See Also:
add(java.awt.Component)

removeAll

public void removeAll()
Removes all the components from this container.

See Also:
add(java.awt.Component), remove(java.awt.Component)

getLayout

public LayoutManager getLayout()
Gets the layout manager for this container.

See Also:
layout(), setLayout(java.awt.LayoutManager)

setLayout

public void setLayout(LayoutManager mgr)
Sets the layout manager for this container.

Parameters:
mgr - the specified layout manager
See Also:
layout(), getLayout()

layout

public void layout()
Does a layout on this Container.

Overrides:
layout in class Component
See Also:
setLayout(java.awt.LayoutManager)

validate

public void validate()
Validates this Container and all of the components contained within it.

Overrides:
validate in class Component
See Also:
validate(), Component.invalidate()

preferredSize

public Dimension preferredSize()
Returns the preferred size of this container.

Overrides:
preferredSize in class Component
See Also:
minimumSize()

minimumSize

public Dimension minimumSize()
Returns the minimum size of this container.

Overrides:
minimumSize in class Component
See Also:
preferredSize()

paintComponents

public void paintComponents(Graphics g)
Paints the components in this container.

Parameters:
g - the specified Graphics window
See Also:
Component.paint(java.awt.Graphics), Component.paintAll(java.awt.Graphics)

printComponents

public void printComponents(Graphics g)
Prints the components in this container.

Parameters:
g - the specified Graphics window
See Also:
Component.print(java.awt.Graphics), Component.printAll(java.awt.Graphics)

deliverEvent

public void deliverEvent(Event e)
Delivers an event. The appropriate component is located and the event is delivered to it.

Overrides:
deliverEvent in class Component
Parameters:
e - the event
See Also:
Component.handleEvent(java.awt.Event), Component.postEvent(java.awt.Event)

locate

public Component locate(int x,
                        int y)
Locates the component that contains the x,y position.

Overrides:
locate in class Component
Parameters:
x - the x coordinate
y - the y coordinate
Returns:
null if the component is not within the x and y coordinates; returns the component otherwise.
See Also:
Component.inside(int, int)

addNotify

public void addNotify()
Notifies the container to create a peer. It will also notify the components contained in this container.

Overrides:
addNotify in class Component
See Also:
removeNotify()

removeNotify

public void removeNotify()
Notifies the container to remove its peer. It will also notify the components contained in this container.

Overrides:
removeNotify in class Component
See Also:
addNotify()

paramString

protected String paramString()
Returns the parameter String of this Container.

Overrides:
paramString in class Component

list

public void list(PrintStream out,
                 int indent)
Prints out a list, starting at the specified indention, to the specified out stream.

Overrides:
list in class Component
Parameters:
out - the Stream name
indent - the start of the list