
 |
Chapter 19 java.awt Reference |
 |
Container
Name
Container
The Container class serves
as a general purpose holder of other Component
objects.
public abstract class java.awt.Container
extends java.awt.Component {
// Constructors
protected Container();
// Instance Methods
public Component add (Component component);
public Component add (Component component, int position);
public void add (Component comp, Object constraints);
public void add (Component comp, Object constraints,
int position);
public Component add (String name, Component component);
public void addContainerListener (ContainerListener l);
public void addNotify();
public int countComponents();
public void deliverEvent (Event e);
public void doLayout();
public float getAlignmentX();
public float getAlignmentY();
public Component getComponent (int n);
public Component getComponentAt (int x, int y);
public Component getComponentAt (Point p);
public int getComponentCount();
public Component[] getComponents();
public Insets getInsets();
public LayoutManager getLayout();
public Dimension getMaximumSize();
public Dimension getMinimumSize();
public Dimension getPreferredSize();
public Insets insets();
public void invalidate();
public boolean isAncestorOf (Component c);
public void layout();
public void list (PrintStream out, int indentation);
public void list (PrintWriter out, int indentation);
public Component locate (int x, int y);
public Dimension minimumSize();
public void paint (Graphics g);
public void paintComponents (Graphics g);
public Dimension preferredSize();
public void print (Graphics g);
public void printComponents (Graphics g);
public void remove (int index);
public void remove (Component component);
public void removeAll();
public void removeContainerListener (ContainerListener l);
public void removeNotify();
public void setLayout (LayoutManager manager);
public void validate();
// Protected Instance Methods
protected void addImpl (Component comp, Object constraints,
int index);
protected String paramString();
protected void processContainerEvent (ContainerEvent e);
protected void processEvent (AWTEvent e);
protected void validateTree();
}
- Description
-
This constructor creates a "lightweight" container. This constructor
allows Container to be subclassed using code written entirely in Java.
- Parameters
-
- component
-
Component
to add to container.
- Returns
-
Component just added.
- Throws
-
IllegalArgumentException if you
add component to itself.
- Description
-
Adds component as the last
component in the container.
- Parameters
-
- component
-
Component
to add to container.
- position
-
Position of component; -1 adds the component as the last
in the container.
- Returns
-
Component just added.
- Throws
-
- ArrayIndexOutOfBoundsException
-
If
position invalid.
- IllegalArgumentException
-
If
you add Component to itself.
- Description
-
Adds component to container
at a certain position.
- Parameters
-
- component
-
Component
to add to container.
- constraints
-
An object describing constraints on the component being
added.
- Description
-
Adds component to container
subject to contraints.
- Parameters
-
- component
-
Component
to add to container.
- constraints
-
An object describing constraints on the component being
added.
- index
-
The position of the component in the container's
list.
- Description
-
Adds component to container
subject to contraints at position
index.
- Parameters
-
- name
-
Name of component being added. This parameter is often
significant to the layout manager of the container (e.g "North",
"Center").
- component
-
Component
to add to container.
- Returns
-
Component just added.
- Throws
-
- IllegalArgumentException
-
If
you add component
to itself.
- Description
-
Adds the component to the container with the given name.
Replaced by the more general add(Component, Object).
- Parameters
-
- l
-
An object that implements the ContainerListener
interface.
- Description
-
Add a listener for the container events.
- Overrides
-
Component.addNotify()
- Description
-
Creates Container's peer and
peers of contained components.
- Returns
-
Number of components within Container.
- Parameters
-
- e
-
Event instance
to deliver.
- Overrides
-
Component.deliverEvent(Event)
- Description
-
Tries to locate the component contained in the container that should receive
the event.
- Description
-
Lays out the container. This method is a replacement for layout().
- Returns
-
A number between 0 and 1 representing the horizontal alignment of this
component.
- Overrides
-
Component.getAlignmentX()
- Description
-
If the container's layout manager implements LayoutManager2,
this method returns the getLayoutAlignmentX()
value of the layout manager. Otherwise the getAlignmentX()
value of Component is returned.
- Returns
-
A number between 0 and 1 representing the vertical alignment of this component.
- Overrides
-
Component.getAlignmentY()
- Description
-
If the container's layout manager implements LayoutManager2,
this method returns the getLayoutAlignmentY()
value of the layout manager. Otherwise the getAlignmentY()
value of Component is returned.
- Parameters
-
- position
-
Position of component to get.
- Throws
-
- ArrayIndexOutOfBoundsException
-
If
position is invalid.
- Returns
-
Component at designated position
within Container.
- Parameters
-
- x
-
The x coordinate, in this Container's
coordinate system.
- y
-
The y coordinate, in this Container's
coordinate system.
- Returns
-
Returns the Component containing
the give point.
- Parameters
-
- p
-
The point to be tested, in this Container's
coordinate system.
- Returns
-
Returns the Component containing
the give point.
- Returns
-
Returns the number of components in the container.
- Returns
-
Array of components within the container.
- Returns
-
The insets of the container.
- Returns
-
LayoutManager of Container.
- Overrides
-
Component.getMaximumSize()
- Returns
-
The maximum dimensions of the component.
- Overrides
-
Component.getMinimumSize()
- Returns
-
The minimum dimensions of the component.
- Returns
-
The preferred dimensions of the component.
- Returns
-
Current Insets of Container.
Replaced by getInsets().
- Overrides
-
Component.invalidate()
- Description
-
Sets the container's valid state to false.
- Parameters
-
- c
-
The component in question.
- Returns
-
If c is contained in the container's
hierarchy, returns true; otherwise
false.
- Overrides
-
Component.layout()
- Description
-
Replaced by doLayout().
- Parameters
-
- out
-
Output Stream
to send results to.
- indentation
-
Indentation to use when printing.
- Overrides
-
Component.list(PrintStream,
int)
- Description
-
Recursively lists all components in Container.
- Parameters
-
- out
-
Output Writer
to send results to.
- indentation
-
Indentation to use when printing.
- Overrides
-
Component.list(PrintWriter,
int)
- Description
-
Recursively lists all components in Container.
- Parameters
-
- x
-
Horizontal position to check.
- y
-
Vertical position to check.
- Returns
-
Component within Container
at given coordinates, or Container.
- Overrides
-
Component.locate(int, int)
- Description
-
Replaced by getComponentAt(int, int).
- Returns
-
Minimum dimensions of contained objects.
- Overrides
-
Component.minimumSize()
- Description
-
Replaced by getMinimumSize().
- Parameters
-
- g
-
Graphics context of container.
- Overrides
-
Component.paint()
- Description
-
This method tells any lightweight components that are children of this
container to paint themselves.
- Parameters
-
- g
-
Graphics context of Container.
- Description
-
Paints the different components in Container.
- Returns
-
Preferred dimensions of contained objects.
- Overrides
-
Component.preferredSize()
- Description
-
Replaced by getPreferredSize().
- Parameters
-
- g
-
Graphics context of container.
- Overrides
-
Component.print()
- Description
-
This method tells any lightweight components that are children of this
container to print themselves.
- Parameters
-
- g
-
Graphics context of Container.
- Description
-
Prints the different components in Container.
- Parameters
-
- index
-
Index of the component to remove.
- Description
-
Removes the component in position index
from Container.
- Parameters
-
- component
-
Component
to remove.
- Description
-
Removes component from Container.
- Description
-
Removes all components from Container.
- Parameters
-
- l
-
One of this Container's
ContainerListeners.
- Description
-
Remove a container event listener.
- Overrides
-
Component.removeNotify()
- Description
-
Removes Container's peer and
peers of contained components.
- Parameters
-
- manager
-
New LayoutManager
for Container.
- Description
-
Changes LayoutManager of Container.
- Overrides
-
Component.validate()
- Description
-
Sets Container's valid
state to true and recursively
validates its children.
- Parameters
-
- comp
-
The component to add.
- constraints
-
Constraints on the component.
- index
-
Position at which to add this component. Pass -1 to add
the component at the end.
- Description
-
This method adds a component subject to the given constraints at a specific
position in the container's list of components. It is a helper method
for the various overrides of add().
- Returns
-
String with current settings of Container.
- Overrides
-
Component.paramString()
- Description
-
Helper method for toString()
to generate string of current settings.
- Parameters
-
- e
-
The event to process.
- Description
-
Container events are passed to this method for processing. Normally, this
method is called by processEvent().
- Parameters
-
- e
-
The event to process.
- Overrides
-
Component.processEvent()
- Description
-
Low level AWTEvents are passed
to this method for processing.
- Description
-
Descends recursively into the Container's
components and recalculates layout for any subtrees that are marked invalid.
Component, Dimension,
Event, Graphics,
Insets, LayoutManager,
Panel, PrintStream,
String, Window
|