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(); }
This constructor creates a "lightweight" container. This constructor allows Container to be subclassed using code written entirely in Java.
Component to add to container.
Component just added.
IllegalArgumentException if you add component to itself.
Adds component as the last component in the container.
Component to add to container.
Position of component; -1 adds the component as the last in the container.
Component just added.
If position invalid.
If you add Component to itself.
Adds component to container at a certain position.
Component to add to container.
An object describing constraints on the component being added.
Adds component to container subject to contraints.
Component to add to container.
An object describing constraints on the component being added.
The position of the component in the container's list.
Adds component to container subject to contraints at position index.
Name of component being added. This parameter is often significant to the layout manager of the container (e.g "North", "Center").
Component to add to container.
Component just added.
If you add component to itself.
Adds the component to the container with the given name. Replaced by the more general add(Component, Object).
An object that implements the ContainerListener interface.
Add a listener for the container events.
Component.addNotify()
Creates Container's peer and peers of contained components.
Number of components within Container.
Event instance to deliver.
Component.deliverEvent(Event)
Tries to locate the component contained in the container that should receive the event.
Lays out the container. This method is a replacement for layout().
A number between 0 and 1 representing the horizontal alignment of this component.
Component.getAlignmentX()
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.
A number between 0 and 1 representing the vertical alignment of this component.
Component.getAlignmentY()
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.
Position of component to get.
If position is invalid.
Component at designated position within Container.
The x coordinate, in this Container's coordinate system.
The y coordinate, in this Container's coordinate system.
Returns the Component containing the give point.
The point to be tested, in this Container's coordinate system.
Returns the Component containing the give point.
Returns the number of components in the container.
Array of components within the container.
The insets of the container.
LayoutManager of Container.
Component.getMaximumSize()
The maximum dimensions of the component.
Component.getMinimumSize()
The minimum dimensions of the component.
The preferred dimensions of the component.
Current Insets of Container. Replaced by getInsets().
Component.invalidate()
Sets the container's valid state to false.
The component in question.
If c is contained in the container's hierarchy, returns true; otherwise false.
Component.layout()
Replaced by doLayout().
Output Stream to send results to.
Indentation to use when printing.
Component.list(PrintStream, int)
Recursively lists all components in Container.
Output Writer to send results to.
Indentation to use when printing.
Component.list(PrintWriter, int)
Recursively lists all components in Container.
Horizontal position to check.
Vertical position to check.
Component within Container at given coordinates, or Container.
Component.locate(int, int)
Replaced by getComponentAt(int, int).
Minimum dimensions of contained objects.
Component.minimumSize()
Replaced by getMinimumSize().
Graphics context of container.
Component.paint()
This method tells any lightweight components that are children of this container to paint themselves.
Graphics context of Container.
Paints the different components in Container.
Preferred dimensions of contained objects.
Component.preferredSize()
Replaced by getPreferredSize().
Graphics context of container.
Component.print()
This method tells any lightweight components that are children of this container to print themselves.
Graphics context of Container.
Prints the different components in Container.
Index of the component to remove.
Removes the component in position index from Container.
Component to remove.
Removes component from Container.
Removes all components from Container.
One of this Container's ContainerListeners.
Remove a container event listener.
Component.removeNotify()
Removes Container's peer and peers of contained components.
New LayoutManager for Container.
Changes LayoutManager of Container.
Component.validate()
Sets Container's valid state to true and recursively validates its children.
The component to add.
Constraints on the component.
Position at which to add this component. Pass -1 to add the component at the end.
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().
String with current settings of Container.
Component.paramString()
Helper method for toString() to generate string of current settings.
The event to process.
Container events are passed to this method for processing. Normally, this method is called by processEvent().
The event to process.
Component.processEvent()
Low level AWTEvents are passed to this method for processing.
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