Class de.unikl.AWTNode.cfContainer
All Packages Class Hierarchy This Package Previous Next Index
Class de.unikl.AWTNode.cfContainer
java.lang.Object
|
+----java.awt.Component
|
+----java.awt.Container
|
+----java.awt.Panel
|
+----de.unikl.AWTNode.cfContainer
- public class cfContainer
- extends Panel
Documentation of the implemenation of cfContainer
Classification mechanism:
Like an ordinary Container the cfContainer contains Components.
The only thing which is unusal is that you can pass with each component
a String. With this String each component gets its identifier.
For what is this good for?
In a Container stands components. Components are painted on the screen
and to do so you need a LayoutManager.
The standard LayoutManager doesnīt distinguish between the components.
e.g: FlowLayout lays out all the Components from left to right, and
GridLayout orders them in rows and colums. But they donīt give a
component a "position" on the screen according to the *kind* of
component during the layout-operation.
In fact there is a LayoutManger which does this: Borderlayout.
But if you look at the source code, the Layoutmanager itsself stores
the "kind" of component. In BorderLayout there a 5 possible kinds
of Components:
"north","south","east","west" and "center".
But because of the assignment in the LayoutManager itsself
you cannot easily replace the LayoutManager with a new one:
Example:
setLayout(new BorderLayout()); // 1
add("Center",mycomp);
setLayout(new BorderLayout()); // 2
doesnīt work, because the second BorderLayouManager doesnīt "know"
about the "pointer" of mycomp.
Thus the attempt to store the compoents in the LayoutManger itsself
leads to problems if you replace the LayouManager.
As a result these "kinds" of Components have to be stored in
the container, and the Implemenation of cfContainer does this
with the "identifiers".(a simple String for each component)
cf stands for [C]lassi[F]ied
Thus you can set for each component you insert its identifier.You can
pass the Identifier in the add-method or seperatly (after the
Component is already added) with the method:
setIdentifier(String name,Component comp)
you can retrieve this identifier with:
getIdentifier(Component comp)
The LayoutManager for a cfContainer may use this identifer to
assign a special position for the component or not.
-
cfContainer()
- Constructs a new [c]lassi[f]ied Container, with an empty
identifier list.
-
add(Component)
- Adds the specified component to this container.
-
add(Component, int)
- Adds the specified component to this container at the given position.
-
add(String, Component)
- Adds the specified component to this container.
-
getComponentCount(String)
- This method return the number of Components which have
the specified filter String as idetifier
-
getComponents(String)
- With this method you have a set-oriented Funktion to
access all Components which match the specific Filter expression
-
getIdentifier(Component)
- returns the identifer of the Component (as String)
or null, if Component does not belong to the Container!
-
getIndex(Component)
- returns the position of the component in the container
-
isContained(Component)
- returns true if the Component is already in the Container,
otherwise false
-
remove(Component)
- Removes the specified component from this container.
-
removeAll()
- Removes all the components from this container.
-
removeAll(String)
- This method removes all Components which have the specified
filter String as identifier
-
setIdentifier(String, Component)
- Sets the identifer for a specified Component.
-
toString()
-
cfContainer
public cfContainer()
- Constructs a new [c]lassi[f]ied Container, with an empty
identifier list.
add
public Component add(Component comp)
- Adds the specified component to this container.
- Parameters:
- comp - the component to be added
- Overrides:
- add in class Container
add
public Component add(Component comp,
int pos)
- Adds the specified component to this container at the given position.
The Identifer added is the empty String ""
- Parameters:
- comp - the component to be added
- pos - the position at which to insert the component. -1
means insert at the end.
- Overrides:
- add in class Container
- See Also:
- remove
add
public Component add(String name,
Component comp)
- Adds the specified component to this container.
The identifier added is the arugument.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
- Overrides:
- add in class Container
- See Also:
- remove, LayoutManager
remove
public void remove(Component comp)
- Removes the specified component from this container.
The Identifer is removed also.
- Parameters:
- comp - the component to be removed
- Overrides:
- remove in class Container
- See Also:
- add
removeAll
public void removeAll()
- Removes all the components from this container.
The Identifer list is cleared
- Overrides:
- removeAll in class Container
- See Also:
- add, remove
getIndex
public int getIndex(Component comp)
- returns the position of the component in the container
- Returns:
- the index of the Coomponent, or -1 if not contained
getIdentifier
public String getIdentifier(Component m)
- returns the identifer of the Component (as String)
or null, if Component does not belong to the Container!
isContained
public boolean isContained(Component comp)
- returns true if the Component is already in the Container,
otherwise false
setIdentifier
public void setIdentifier(String name,
Component comp)
- Sets the identifer for a specified Component. If Component
is not contained in cfContainer, nothing is done!
getComponentCount
public final int getComponentCount(String filter)
- This method return the number of Components which have
the specified filter String as idetifier
- Parameters:
- filtered - components must have this identifer
- Returns:
- s number of Components which have the as identifier
getComponents
public final Component[] getComponents(String filter)
- With this method you have a set-oriented Funktion to
access all Components which match the specific Filter expression
- Parameters:
- filtered - components must have this identifer
- Returns:
- s all the Component which have the String filter as identifier
removeAll
public void removeAll(String filter)
- This method removes all Components which have the specified
filter String as identifier
toString
public String toString()
- Overrides:
- toString in class Component
All Packages Class Hierarchy This Package Previous Next Index