java.awt
Class Container

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

public class Container
extends Component

A special component that can contain other components.


Constructor Summary
Container()
          Creates a new container with a default flow layout.
Container(LayoutManager layoutManager)
          Creates a new container with the given layoutManager.
 
Method Summary
 Component add(Component c)
          Adds the given component to this container.
 void add(Component c, java.lang.Object where)
          Adds the given component with the given constraints to this container
 Component add(java.lang.String where, Component c)
          Adds the givn component at the given position.
 void addImpl(Component c, java.lang.Object constraints, int index)
          This add method encapsulates the real implementation and is called by all other add methods.
 void doLayout()
          Forces new layout of this container.
 Component findComponentAt(int px, int py)
          returns the component at the given position.
 Component getComponent(int i)
          Returns the component at the given index.
 int getComponentCount()
          Returns the number of child components in this container.
 Component[] getComponents()
          Returns a Component array containing all child components of this container.
 Insets getInsets()
           
 LayoutManager getLayout()
          Returns the LayoutManger assigned to this Container.
 Dimension getMinimumSize()
          Returns the minimum size of this container, depending on the current layout manager.
 boolean isAncestorOf(Component c)
          returns if this container contains the given component or any container containing the given component.
 boolean isFocusTraversable()
          Returns false
 void paintAll(Graphics g)
          Paints this component and all child components.
 void paintComponents(Graphics g)
          Paints all child components.
 void remove(Component c)
          Removes the given component from this container.
 void remove(int i)
          Removes the component at the given index from this container.
 void removeAll()
          Removes all components from this container.
 void setLayout(LayoutManager mgr)
          Sets the given layout manager.
 void update(Graphics g)
          This method clears the background using the current background color and calls paintAll.
 void validate()
          Calls doLayout if the current layout is not valid. (inValidate has been called before).
 
Methods inherited from class java.awt.Component
addFocusListener, addKeyListener, addMouseListener, addMouseMotionListener, contains, dispatchEvent, enableEvents, getBackground, getBounds, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getLocationOnScreen, getMaximumSize, getParent, getPreferredSize, getSize, getWidth, getX, getY, hasFocus, invalidate, isEnabled, isValid, isVisible, paint, processEvent, processFocusEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, repaint, repaint, requestFocus, setBackground, setBounds, setEnabled, setFont, setForeground, setLocation, setSize, setSize, setVisible
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Container

public Container()
Creates a new container with a default flow layout.

Container

public Container(LayoutManager layoutManager)
Creates a new container with the given layoutManager. If the parameter is set to null, no layoutmanager is associated with this container and the child components must be positioned manually using e.g. setBounds.
Method Detail

add

public Component add(Component c)
Adds the given component to this container.

add

public Component add(java.lang.String where,
                     Component c)
Adds the givn component at the given position.

add

public void add(Component c,
                java.lang.Object where)
Adds the given component with the given constraints to this container

addImpl

public void addImpl(Component c,
                    java.lang.Object constraints,
                    int index)
This add method encapsulates the real implementation and is called by all other add methods.

findComponentAt

public Component findComponentAt(int px,
                                 int py)
returns the component at the given position. If there is no subcomponent at the given position, this is returned.
Overrides:
findComponentAt in class Component

getComponent

public Component getComponent(int i)
Returns the component at the given index.

getComponentCount

public int getComponentCount()
Returns the number of child components in this container.

getComponents

public Component[] getComponents()
Returns a Component array containing all child components of this container.

getInsets

public Insets getInsets()

getMinimumSize

public Dimension getMinimumSize()
Returns the minimum size of this container, depending on the current layout manager.
Overrides:
getMinimumSize in class Component

isFocusTraversable

public boolean isFocusTraversable()
Returns false
Overrides:
isFocusTraversable in class Component

isAncestorOf

public boolean isAncestorOf(Component c)
returns if this container contains the given component or any container containing the given component.

getLayout

public LayoutManager getLayout()
Returns the LayoutManger assigned to this Container.

paintAll

public void paintAll(Graphics g)
Paints this component and all child components.
Overrides:
paintAll in class Component

paintComponents

public void paintComponents(Graphics g)
Paints all child components. May be removed from kAWT, so please do not use this function.

removeAll

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

remove

public void remove(int i)
Removes the component at the given index from this container.

remove

public void remove(Component c)
Removes the given component from this container.

setLayout

public void setLayout(LayoutManager mgr)
Sets the given layout manager.

update

public void update(Graphics g)
This method clears the background using the current background color and calls paintAll. Attention: If only one child component hits the current clip are, this child is repaint without the paintAll indirection.
Overrides:
update in class Component

doLayout

public void doLayout()
Forces new layout of this container. Call validate in order to perform a new layout only when really neede.

validate

public void validate()
Calls doLayout if the current layout is not valid. (inValidate has been called before).
Overrides:
validate in class Component