|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object portal.core.api.Component portal.core.api.Container
This is the base class for all components that can contain a list of children. This class manages the link between these child components and their parent (this Container instance).
The rendering of this container is delegated to layout managers. Setting a layout
manager for a container is done by calling the method
Component.setLayout(LayoutManager)
.
Some layout managers require more information to render the children of the container.
For these specific layout managers you can pass a value to the constraint paramater
of the add(...) methods. The actual value is only interpreted by the layout
manager. See the documentation of the
layout manager
used for possible values and their
meaning.
Constructor Summary | |
Container()
Create a new Container instance. |
|
Container(LayoutManager layout)
Create a new Container instance with an initial layout manager. |
|
Container(java.lang.String name,
LayoutManager layout)
Create a new Container instance with the give name and layout manager. |
Method Summary | |
void |
add(Component component)
Add a new child component to this container with no constraint. |
void |
add(Component component,
java.lang.Object constraint)
Add a new child component to this container with the given constraint. |
void |
add(int index,
Component component,
java.lang.Object constraint)
Add a new child component to this container with the given constraint and at the given index. |
Component |
getComponent(int index)
Return the child component at the given index. |
Component |
getComponent(java.lang.Object constraint)
Search for the first component in this container that uses the given constraint. |
java.util.Collection |
getComponents()
Creates a copy of the current list of child components in this container. |
java.lang.Object |
getConstraint(int index)
Return the constraint used by the child component at the given index. |
void |
remove(Component component)
Remove the given child component from this container if present. |
void |
remove(int index)
Removes the child at the given index. |
void |
remove(java.lang.Object constraint)
Find the first child component that has a constraint equal to the given constraint and remove the child component. |
void |
removeAll()
Remove all children with their constraints from this container instance. |
int |
size()
Returns the size of this container. |
Methods inherited from class portal.core.api.Component |
afterRender, beforeRender, createDefaultModel, draw, getLayout, getModel, getParent, isEnabled, isVisible, render, setEnabled, setLayout, setModel, setParent, setVisible, toString |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public Container()
Create a new Container instance.
Calling this constructor is is identical to calling Container(String,LayoutManager)
with a name equal to null and a layout equal to null.
For this container to be rendered, you have to call the method
Component.setLayout(LayoutManager)
and set a
layout manager.
public Container(LayoutManager layout)
Create a new Container instance with an initial layout manager.
Calling this constructor is is identical to calling Container(String,LayoutManager)
with a name equal to null.
layout
- the initial layout manager for this containerpublic Container(java.lang.String name, LayoutManager layout)
Create a new Container instance with the give name and layout
manager. The layout manager can be replaced by a later call to
Component.setLayout(LayoutManager)
See also Component.Component(String)
.
name
- the name of this containerlayout
- the initial layout manager for this containerMethod Detail |
public final void add(Component component)
Add a new child component to this container with no constraint. Calling this method
is identical to calling add(Component,Object)
with a constraint value of null.
component
- The child component to add to this container.public final void add(Component component, java.lang.Object constraint)
Add a new child component to this container with the given constraint. The possible values of the constraint paramater depend on the layout manager used to render this container. Some layout managers even ignore this value.
The parent of the child component is updated to be this container. If the child belonged to another container, it will be removed from that container first.
component
- The child component to add to this container.constraint
- The constraint used to add this child component to this container.public final void add(int index, Component component, java.lang.Object constraint)
Add a new child component to this container with the given constraint and at the given index.
The actual orderering of the items within the container is only used by the layout manager and may be ignored.
See also add(Component,Object)
for more information.
index
- The index at which to add this child component.component
- The child component to add to this container.constraint
- The constraint used to add this child component to this container.public final void remove(Component component)
Remove the given child component from this container if present. If the child component is not present in this container, nothing will happen.
The parent of the child component will be set to null before the child is removed.
component
- the child component that has to be removed.public final void remove(java.lang.Object constraint)
Find the first child component that has a constraint equal to the given constraint and remove the child component. If there is no such constraint used in this container, nothing happens.
The parent of the child component will be set to null before the child is removed.
constraint
- the constraint for which the child has to be removed.public final void remove(int index)
Removes the child at the given index. The index has to be within the bounds set by the container (< size() and >= 0).
The parent of the child component will be set to null before the child is removed.
index
- the index of the child componet that has to be removed.public final void removeAll()
Remove all children with their constraints from this container instance. The result is an empty container.
The parent of all child components will be set to null before the child is removed.
public final int size()
Returns the size of this container. The size is set to be equal to the number of components in this container.
public final java.lang.Object getConstraint(int index)
Return the constraint used by the child component at the given index. The index has to be within the bounds set by the container (< size() and >= 0).
It is possible that the child component at the given index does not use a constraint. In that case null will be returned.
index
- the index within the container to search at.
public final Component getComponent(int index)
Return the child component at the given index. The index has to be within the bounds set by the container (< size() and >= 0).
index
- the index within the container to search at.
public final java.util.Collection getComponents()
Creates a copy of the current list of child components in this container. The resulting collection can be manipulated without affecting the container.
public final Component getComponent(java.lang.Object constraint)
Search for the first component in this container that uses the given constraint. If no such component is found, null is returned.
constraint
- the constraint to search for. Cannot be null.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |