org.wings
Class SContainer

java.lang.Object
  extended by org.wings.SComponent
      extended by org.wings.SContainer
All Implemented Interfaces:
Serializable, Cloneable, Renderable
Direct Known Subclasses:
SAnchor, SCellRendererPane, SDesktopPane, SForm, SMenuBar, SPanel, SRootContainer, SScrollPane, STabbedPane, XCalendar, XDivision, XPageScroller

public class SContainer
extends SComponent

Can hold several other SComponents.

Author:
Armin Haaf
See Also:
SLayoutManager, SComponent, Serialized Form

Field Summary
 
Fields inherited from class org.wings.SComponent
DONE_RENDERING, dynamicStyles, enabled, propertyChangeSupport, SELECTOR_ALL, START_RENDERING, visible, WHEN_FOCUSED_OR_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_IN_FOCUSED_FRAME
 
Constructor Summary
SContainer()
          creates a new container with a Flowlayout as layout manager, like the Swing default.
SContainer(SLayoutManager l)
          creates a new container with the given layout
 
Method Summary
 SComponent add(SComponent c)
          Adds a component to the container with null constraint at the end of the internal list.
 SComponent add(SComponent c, int index)
          Adds a component to the container with null constraint at the given index.
 void add(SComponent c, Object constraint)
          Adds a component to the container with the given constraint at the end of the internal list.
 void add(SComponent c, Object constraint, int index)
          Adds a component to the container with the given constraint at the given index.
 SComponent addComponent(SComponent c)
          Adds a component to the container with null constraint at the end of the internal list.
 SComponent addComponent(SComponent c, int index)
          Adds a component to the container with the given constraint at the given index.
 SComponent addComponent(SComponent c, Object constraint)
          Adds a component to the container with the given constraint at the end of the internal list.
 SComponent addComponent(SComponent c, Object constraint, int index)
          Adds a component to the container with the given constraint at the given index.
 void addContainerListener(SContainerListener l)
          Adds the specified container listener to receive container events from this container.
 void addNotify()
          Method called to notify this SComponent that it has a new parent component.
 Object clone()
          CAVEAT this did not work yet...
protected  void fireContainerEvent(int type, SComponent comp)
           
 SComponent getComponent(int i)
          returns the component at the given position
 int getComponentCount()
          returns the number of components in this container
protected  ArrayList getComponentList()
           
 SComponent[] getComponents()
           
 Object getConstraintAt(int i)
          returns the constraint for the given component position
protected  ArrayList getConstraintList()
           
 SLayoutManager getLayout()
          Returns the current layout
 void invite(ComponentVisitor visitor)
          Invite a ComponentVisitor.
 void inviteEachComponent(ComponentVisitor visitor)
          Calls the visitor on each SComponent this container has.
protected  boolean isShowingChildren()
          Indicates if this container is actually showing it's children.
protected  void processContainerEvent(SContainerListener listener, SContainerEvent e)
          Processes container events occurring on this container by dispatching them to any registered ContainerListener objects.
 void remove(int index)
          Removes the component at the given position from the container.
 void remove(SComponent c)
          Removes the given component from the container.
 void removeAll()
          Removes all components from the container.
 void removeContainerListener(SContainerListener l)
          Removes the specified container listener so it no longer receives container events from this container.
 void removeNotify()
          Method called to notify this SComponent that it has no longer a parent component.
 void setCG(ContainerCG cg)
           
 void setLayout(SLayoutManager l)
          Sets a new layout manager.
protected  void setParentFrame(SFrame f)
          Sets the parent frame.
 void updateCG()
          Notification from the CGFactory that the L&F has changed.
 
Methods inherited from class org.wings.SComponent
addComponentListener, addDynamicStyle, addEventListener, addParentFrameListener, addPropertyChangeListener, addPropertyChangeListener, addRenderListener, addScriptListener, addStyle, fireComponentChangeEvent, fireFinalEvents, fireKeyEvents, fireRenderEvent, getActionMap, getBackground, getBorder, getCG, getClientProperty, getComponentPopupMenu, getDynamicStyle, getDynamicStyles, getFocusTraversalIndex, getFont, getForeground, getHorizontalAlignment, getInputMap, getInputMap, getListenerCount, getListenerList, getListeners, getLowLevelEventId, getName, getParent, getParentFrame, getPreferredSize, getRequestURL, getResidesInForm, getScriptListenerList, getScriptListeners, getSession, getShowAsFormComponent, getStyle, getToolTipText, getVerticalAlignment, isDifferent, isEnabled, isFocusOwner, isRecursivelyVisible, isReloadForced, isUpdatePossible, isVisible, paramString, processComponentEvent, processKeyEvents, processLowLevelEvent, putClientProperty, reload, reloadIfChange, reloadIfChange, reloadIfChange, reloadIfChange, reloadIfChange, reloadIfChange, reloadIfChange, reloadIfChange, reloadIfChange, removeComponentListener, removeDynamicStyle, removeEventListener, removeParentFrameListener, removePropertyChangeListener, removePropertyChangeListener, removeRenderListener, removeScriptListener, removeStyle, requestFocus, scrollRectToVisible, setActionMap, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttributes, setBackground, setBorder, setCG, setComponentPopupMenu, setDynamicStyles, setEnabled, setFocusTraversalIndex, setFont, setForeground, setHorizontalAlignment, setInputMap, setInputMap, setName, setNameRaw, setParent, setPreferredSize, setReloadForced, setShowAsFormComponent, setStyle, setToolTipText, setVerticalAlignment, setVisible, toString, update, write
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SContainer

public SContainer(SLayoutManager l)
creates a new container with the given layout

Parameters:
l - the layout for this container

SContainer

public SContainer()
creates a new container with a Flowlayout as layout manager, like the Swing default.

Method Detail

updateCG

public void updateCG()
Description copied from class: SComponent
Notification from the CGFactory that the L&F has changed.

Overrides:
updateCG in class SComponent
See Also:
SComponent.updateCG()

setLayout

public void setLayout(SLayoutManager l)
Sets a new layout manager.

Parameters:
l - new layout manager

getLayout

public SLayoutManager getLayout()
Returns the current layout

Returns:
current layout

addContainerListener

public void addContainerListener(SContainerListener l)
Adds the specified container listener to receive container events from this container. If l is null, no exception is thrown and no action is performed.

Parameters:
l - the container listener

removeContainerListener

public void removeContainerListener(SContainerListener l)
Removes the specified container listener so it no longer receives container events from this container. If l is null, no exception is thrown and no action is performed.

Parameters:
l - the container listener

fireContainerEvent

protected void fireContainerEvent(int type,
                                  SComponent comp)

processContainerEvent

protected void processContainerEvent(SContainerListener listener,
                                     SContainerEvent e)
Processes container events occurring on this container by dispatching them to any registered ContainerListener objects. NOTE: This method will not be called unless container events are enabled for this component; this happens when one of the following occurs: a) A ContainerListener object is registered via addContainerListener() b) Container events are enabled via enableEvents()

Parameters:
e - the container event

getComponentList

protected ArrayList getComponentList()

getConstraintList

protected ArrayList getConstraintList()

getComponentCount

public int getComponentCount()
returns the number of components in this container

Returns:
number of components

getComponent

public SComponent getComponent(int i)
returns the component at the given position

Parameters:
i - position
Returns:
component at given pos

getComponents

public SComponent[] getComponents()

getConstraintAt

public Object getConstraintAt(int i)
returns the constraint for the given component position

Parameters:
i - position
Returns:
constraint for component at given position

remove

public void remove(SComponent c)
Removes the given component from the container.

Parameters:
c - the component to remove
See Also:
remove(org.wings.SComponent)

remove

public void remove(int index)
Removes the component at the given position from the container.

Parameters:
index - remove the component at position index from this container

removeAll

public void removeAll()
Removes all components from the container.


add

public SComponent add(SComponent c)
Adds a component to the container with null constraint at the end of the internal list.

Parameters:
c - the component to add
Returns:
the added component

add

public void add(SComponent c,
                Object constraint)
Adds a component to the container with the given constraint at the end of the internal list.

Parameters:
c - the component to add
constraint - the constraint for this component

add

public SComponent add(SComponent c,
                      int index)
Adds a component to the container with null constraint at the given index.

Parameters:
c - the component to add
index - the index of the component
Returns:
the added component

add

public void add(SComponent c,
                Object constraint,
                int index)
Adds a component to the container with the given constraint at the given index.

Parameters:
c - the component to add
index - the index of the component

addComponent

public SComponent addComponent(SComponent c)
Adds a component to the container with null constraint at the end of the internal list.

Parameters:
c - the component to add
Returns:
the added component

addComponent

public SComponent addComponent(SComponent c,
                               Object constraint)
Adds a component to the container with the given constraint at the end of the internal list.

Parameters:
c - the component to add
constraint - the constraint for this component
Returns:
the added component

addComponent

public SComponent addComponent(SComponent c,
                               int index)
Adds a component to the container with the given constraint at the given index.

Parameters:
c - the component to add
index - the index of the component
Returns:
the added component

addComponent

public SComponent addComponent(SComponent c,
                               Object constraint,
                               int index)
Adds a component to the container with the given constraint at the given index.

Parameters:
c - the component to add
index - the index of the component
Returns:
the added component

setParentFrame

protected void setParentFrame(SFrame f)
Sets the parent frame.

Overrides:
setParentFrame in class SComponent
Parameters:
f - parent frame

clone

public Object clone()
CAVEAT this did not work yet... We need to clone the layout manager as well, so SLayoutManager must be Cloneable

Overrides:
clone in class SComponent
Returns:
a clone of this component

setCG

public void setCG(ContainerCG cg)

invite

public void invite(ComponentVisitor visitor)
            throws Exception
Invite a ComponentVisitor. Invokes visit(SContainer) on the ComponentVisitor.

Overrides:
invite in class SComponent
Parameters:
visitor - the visitor to be invited
Throws:
Exception

inviteEachComponent

public void inviteEachComponent(ComponentVisitor visitor)
                         throws Exception
Calls the visitor on each SComponent this container has. You might want to call this in your visitor in visit(SContainer).

Parameters:
visitor - an implementation of the ComponentVisitor interface.
Throws:
Exception

removeNotify

public void removeNotify()
Description copied from class: SComponent
Method called to notify this SComponent that it has no longer a parent component. This Method is called internal and should not be called directly, but can be overerloaded to react on this event.

Overrides:
removeNotify in class SComponent

addNotify

public void addNotify()
Description copied from class: SComponent
Method called to notify this SComponent that it has a new parent component. This Method is called internal and should not be called directly, but can be overerloaded to react on this event.

Overrides:
addNotify in class SComponent

isShowingChildren

protected boolean isShowingChildren()
Indicates if this container is actually showing it's children. Default is true

Returns:
true if getComponents() are rendered, false if i.e the container hides them (i.e minimized MDI window).


wingS Swings ;-)