|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object jcontrol.ui.wombat.Component jcontrol.ui.wombat.Container
public class Container
A container object is a component that can contain other components.
Containers are used to group components that should e.g. become visible or invisible
at the same time, have the same font, being replaced by other components all at once etc.
Normally, it is not nescessary to define any bounds for a container as component bounds are
always treated as absolute display coordinates. Thus, components simply ignore their
parent's bounds.
Components added to a container are tracked in an array. If the number
of added components exceeds the initial array size, the array will be resized, i.e. enlarged.
Removing a component will not immediately dispose the component or delete the corresponding array index.
First, the component is marked as to be deleted, then, on the next paint event, the graphic
area covered by the component is cleared and the array index the component is stored in is set to
null
.
In other words, removing a component will not result in a smaller data array. The array is neither
trimmed nor are the components beyond the removed one shifted forward. Adding a component to
the container will use the first free index in the array to store it in. Consequentely in a container,
components are not necessarily stored in the same order they have been added.
Border
.
(c) Copyright 2005-2007 DOMOLOGIC GmbH
IFrame
Field Summary |
---|
Constructor Summary | |
---|---|
Container()
Create a new Container with a default initial capacity of 10. |
|
Container(int estimatedMaxCapacity)
Constructs a new Container. |
Method Summary | |
---|---|
void |
add(Component component)
Adds a child component to this container. |
protected void |
dispose()
|
void |
paint(XGraphics g)
Does nothing. |
void |
remove(Component component)
Removes a child component from the container. |
void |
removeAll()
Removes all child components from this container. |
void |
repaint()
Causes a repaint for this container and all sub-components. |
void |
repaintAll()
Causes the entire component to be marked as needing to be redrawn. |
void |
setBackgroundColor(Color background)
Sets the background color for this container and all sub-components. |
protected void |
setBackgroundColorInternal(Color background)
|
boolean |
setDirty(Object source,
int x,
int y,
int width,
int height,
int newstate,
boolean onoff)
For internal use only. |
void |
setFont(Resource font)
Set a font for this container and all sub-components that do not have their own font specified. |
void |
setForegroundColor(Color foreground)
Sets the foreground color for this container and all sub-components. |
protected void |
setForegroundColorInternal(Color foreground)
|
protected void |
setParametersInternal(Resource font,
Color foregroundColor,
Color backgroundColor,
Color transparentColor)
|
void |
setTransparentColor(Color transparentColor)
Sets the transparent color for this container and all sub-components. |
void |
setVisible(boolean visible)
Sets this container and all child components visible or invisible. |
void |
update(XGraphics g)
Paints all child components. |
Methods inherited from class jcontrol.ui.wombat.Component |
---|
drawDisabledImage, getFrame, isEnabled, isVisible, isVisibleInternal, redrawInternalAndParent, safeExec, setBounds, setDirty, setEnabled, setRedraw, unsafeExec |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, notifyAll, toString, wait |
Constructor Detail |
---|
public Container(int estimatedMaxCapacity)
Constructs a new Container. Containers can be extended, but are lightweight in this case and must be contained by a parent somewhere higher up in the component tree (such as Frame for example).
The parameter estimatedMaxCapacity
specifies the initial size of the internal data
array the components will be stored in.
If this number is exceeded the array will be resized, indeed. But this may consume a lot of memory.
For a short period of time, two data arrays must be kept in memory simultaniously to copy the data
from the small array to the larger one. In large applications this may exceed the available memory.
To avoid this, it is recommended to initialize the container as big as it must never be enlarged any
time. But it should of course neither be too large as then, memory will be allocated that is never
used by the application.
In most cases, it is quite easy for the programmer to know the number of components a container
should hold. In simple applications, components are once added an never removed. Thus, it is easy to
count them. When components should be removed and replaced by other ones at run-time, the maximum capacity
should include the sum of both, removed and newly added components. This is because of the fact that
removed components are not deleted from the data array immediately but on the next painting action.
estimatedMaxCapacity
- the capacity the internal data array should be initialized withContainer()
public Container()
Container
with a default initial capacity of 10. Using this constructor corresponds to the call
new Container(10)
.
Container(int estimatedMaxCapacity)
Method Detail |
---|
public void add(Component component)
add
in interface IContainer
component
- the component to add.public void remove(Component component)
remove
in interface IContainer
component
- the component to removeprotected void setParametersInternal(Resource font, Color foregroundColor, Color backgroundColor, Color transparentColor)
setParametersInternal
in class Component
public void setFont(Resource font)
setFont
in class Component
font
- the new font.Component.setFont(Resource font)
protected void setForegroundColorInternal(Color foreground)
setForegroundColorInternal
in class Component
protected void setBackgroundColorInternal(Color background)
setBackgroundColorInternal
in class Component
public void setForegroundColor(Color foreground)
setForegroundColor
in class Component
foreground
- the foreground color to setpublic void setTransparentColor(Color transparentColor)
setTransparentColor
in class Component
transparentColor
- the transparent color to setpublic void setBackgroundColor(Color background)
setBackgroundColor
in class Component
background
- the background color to setpublic void repaint()
repaint
in class Component
Component.repaint()
public void repaintAll()
repaintAll
in class Component
protected void dispose()
public void removeAll()
removeAll
in interface IContainer
public void setVisible(boolean visible)
setVisible
in class Component
visible
- true
- visible, false
- invisibleComponent.setVisible(boolean visible)
public void paint(XGraphics g)
paint
in class Component
g
- the application's graphics object.public void update(XGraphics g)
update
in class Component
g
- the application's graphics object.Component.update(XGraphics g)
public boolean setDirty(Object source, int x, int y, int width, int height, int newstate, boolean onoff)
setDirty
in interface IContainer
newstate
- the state to set
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |