com.extjs.gxt.ui.client.widget
Class LayoutContainer

java.lang.Object
  extended by com.google.gwt.user.client.ui.UIObject
      extended by com.google.gwt.user.client.ui.Widget
          extended by com.extjs.gxt.ui.client.widget.Component
              extended by com.extjs.gxt.ui.client.widget.BoxComponent
                  extended by com.extjs.gxt.ui.client.widget.Container<T>
                      extended by com.extjs.gxt.ui.client.widget.ScrollContainer<Component>
                          extended by com.extjs.gxt.ui.client.widget.LayoutContainer
All Implemented Interfaces:
Observable, com.google.gwt.event.logical.shared.HasAttachHandlers, com.google.gwt.event.shared.HasHandlers, com.google.gwt.user.client.EventListener, com.google.gwt.user.client.ui.IsWidget
Direct Known Subclasses:
CardPanel, ContentPanel, FieldSet, HorizontalPanel, Popup, TabItem, TaskBar, VerticalPanel, Viewport

public class LayoutContainer
extends ScrollContainer<Component>

A Container that lays out its children using a Layout. Layouts are responsible for connecting the child components to the container. Layouts are very flexible as they can create any internal element structure, inserting its child components at any location. For example, a TableLayout lays out its children using HTML tables.

Many layouts support layout data which are configurable objects that provide additional information to the layout. These objects can be passed when adding and inserting child components into the container. Each layout will document if and what layout data it supports.

Code snippet:
 LayoutContainer container = new LayoutContainer();
 container.add(new Button("Click Me"));
 container.setSize(300, 300);
 container.setBorders(true);
 RootPanel.get().add(container);
FlowLayout is the the default layout and will be used if not a layout is not specified. You must size/position containers unless they are in an existing container that lays out its children.

Events:
AfterLayout : ContainerEvent(container)
Fires when the widgets in this container are arranged by the associated layout.
Inherited Events:
ScrollContainer Scroll
Container BeforeAdd
Container Add
Container BeforeRemove
Container Remove
BoxComponent Move
BoxComponent Resize
Component Enable
Component Disable
Component BeforeHide
Component Hide
Component BeforeShow
Component Show
Component Attach
Component Detach
Component BeforeRender
Component Render
Component BrowserEvent
Component BeforeStateRestore
Component StateRestore
Component BeforeStateSave
Component SaveState

See Also:
Layout

Nested Class Summary
 
Nested classes/interfaces inherited from class com.google.gwt.user.client.ui.UIObject
com.google.gwt.user.client.ui.UIObject.DebugIdImpl, com.google.gwt.user.client.ui.UIObject.DebugIdImplEnabled
 
Field Summary
 
Fields inherited from class com.extjs.gxt.ui.client.widget.Container
attachChildren, enableLayout, layoutExecuted, layoutNeeded, layoutOnAttach, layoutOnChange
 
Fields inherited from class com.extjs.gxt.ui.client.widget.BoxComponent
adjustSize, cacheSizes, ensureVisibilityOnSizing, height, lastSize, layer, shim, width
 
Fields inherited from class com.extjs.gxt.ui.client.widget.Component
afterRender, attachables, baseStyle, disabled, disabledStyle, disableTextSelection, dummy, focusable, hidden, mask, maskMessage, maskMessageStyleName, monitorWindowResize, rendered, resizeHandler, setElementRender, stateId, swallowEvents, toolTip, windowResizeDelay, windowResizeTask
 
Fields inherited from class com.google.gwt.user.client.ui.UIObject
DEBUG_ID_PREFIX
 
Constructor Summary
LayoutContainer()
          Creates a new layout container.
LayoutContainer(Layout layout)
          Creates a new layout container.
 
Method Summary
 boolean add(com.google.gwt.user.client.ui.Widget widget)
          Adds a widget to this Container.
 boolean add(com.google.gwt.user.client.ui.Widget widget, LayoutData layoutData)
          Adds a widget to this Container.
 Html addText(java.lang.String text)
          Creates a new HTML instance and adds it to the container.
 WidgetComponent findComponent(com.google.gwt.user.client.ui.Widget widget)
          Returns the widget component that wraps the given widget.
 Layout getLayout()
          Returns the layout which is associated with the container, or null if one has not been set.
 El getLayoutTarget()
          Override this method to specify the element to be used by the layout as the container.
 int getWindowResizeDelay()
          Returns the window resize delay.
 boolean insert(com.google.gwt.user.client.ui.Widget widget, int index)
          Inserts a widget into this Container at a specified index.
 boolean insert(com.google.gwt.user.client.ui.Widget widget, int index, LayoutData layoutData)
          Inserts a widget into this Container at a specified index.
 boolean isLayoutOnChange()
          Returns true if the layout will be executed when widgets are added or removed.
 boolean isMonitorWindowResize()
          Returns true if browser resizing is monitored
 boolean layout()
          Executes the container's layout.
 boolean layout(boolean force)
          * Executes the container's layout.
protected  void onBlur(ComponentEvent ce)
           
 void onComponentEvent(ComponentEvent ce)
          Any events a component receives will be forwarded to this method.
protected  void onFocus(ComponentEvent ce)
           
protected  void onRender(com.google.gwt.user.client.Element parent, int index)
          Subclasses must override and ensure setElement is called for lazy rendered components.
 boolean remove(com.google.gwt.user.client.ui.Widget widget)
          Removes a component from this container.
 boolean removeAll()
          Removes all of children from this container.
 void setLayout(Layout layout)
          Sets the container's layout.
 void setLayoutData(Component component, LayoutData layoutData)
          Sets the component's layout data.
 void setLayoutOnChange(boolean layoutOnChange)
          Specifies if the container's layout should be called when widgets are added or removed.
 void setMonitorWindowResize(boolean monitorWindowResize)
          True to have onWindowResize executed when the browser window is resized (default to false).
 void setWindowResizeDelay(int delay)
          Sets delay in milliseconds used to buffer window resizing (defaults to 100).
 
Methods inherited from class com.extjs.gxt.ui.client.widget.ScrollContainer
addScrollListener, afterRender, getHScrollPosition, getScrollMode, getVScrollPosition, removeScrollListener, scrollIntoView, setHScrollPosition, setScrollMode, setVScrollPosition
 
Methods inherited from class com.extjs.gxt.ui.client.widget.Container
add, adjustIndex, adopt, createContainerEvent, disable, doAttachChildren, doDetachChildren, doLayout, doLayout, enable, findItem, getItem, getItemByItemId, getItemCount, getItems, getWidget, indexOf, insert, isLayoutNeeded, iterator, notifyHide, notifyShow, onAfterLayout, onAttach, onBeforeLayoutExcecuted, onInsert, onLayoutExcecuted, onRemove, orphan, remove, remove, removeAll, scrollIntoView, setLayoutNeeded, wrapWidget
 
Methods inherited from class com.extjs.gxt.ui.client.widget.BoxComponent
adjustPosition, adjustSize, createComponentEvent, getBounds, getHeight, getHeight, getPosition, getPositionEl, getResizeEl, getShadow, getShadowOffset, getShadowPosition, getSize, getWidth, getWidth, hideShadow, hideShim, hideUnders, isAutoHeight, isAutoWidth, isDeferHeight, isShim, onHide, onPosition, onResize, onShow, onUnload, setAutoHeight, setAutoWidth, setBounds, setBounds, setDeferHeight, setHeight, setHeight, setPagePosition, setPagePosition, setPixelSize, setPosition, setShadow, setShadowOffset, setShadowPosition, setShim, setSize, setSize, setWidth, setWidth, sync, syncSize
 
Methods inherited from class com.extjs.gxt.ui.client.widget.Component
addAttachable, addListener, addPlugin, addStyleName, addStyleOnOver, addWidgetListener, applyState, assertAfterRender, assertPreRender, beforeRender, blur, clearState, createObservable, createStyles, disableContextMenu, disableEvents, disableTextSelection, el, enableEvents, fireEvent, fireEvent, fireEvent, fly, focus, frame, getAriaSupport, getBaseStyle, getBorders, getContextMenu, getData, getElement, getFocusEl, getFocusSupport, getHideMode, getId, getItemId, getListeners, getModel, getObservable, getPlugins, getState, getStateId, getTabIndex, getTitle, getToolTip, hasListeners, hasListeners, hide, hideToolTip, initState, isDisabledEvents, isDisableTextSelection, isEnabled, isMasked, isRendered, isStateful, isVisible, isVisible, mask, mask, mask, onBrowserEvent, onDetach, onDetachHelper, onDisable, onEnable, onEnsureDebugId, onHideContextMenu, onLoad, onRightClick, onShowContextMenu, onWindowResize, previewEvent, recalculate, removeAllListeners, removeAttachagle, removeFromParent, removeListener, removeStyleName, removeStyleOnOver, removeSwallow, removeToolTip, removeWidgetListener, render, render, repaint, saveState, setAriaRole, setAriaState, setAriaSupport, setBorders, setContextMenu, setData, setEl, setElement, setElement, setEnabled, setFiresEvents, setHideMode, setId, setIntStyleAttribute, setItemId, setModel, setParent, setStateful, setStateId, setStyleAttribute, setStyleName, setTabIndex, setTitle, setToolTip, setToolTip, setVisible, setZIndex, show, sinkEvents, swallowEvent, swallowEvent, toString, unframe, unmask
 
Methods inherited from class com.google.gwt.user.client.ui.Widget
addAttachHandler, addBitlessDomHandler, addDomHandler, addHandler, asWidget, asWidgetOrNull, createHandlerManager, delegateEvent, fireEvent, getHandlerCount, getLayoutData, getParent, isAttached, isOrWasAttached, setLayoutData
 
Methods inherited from class com.google.gwt.user.client.ui.UIObject
addStyleDependentName, ensureDebugId, ensureDebugId, ensureDebugId, getAbsoluteLeft, getAbsoluteTop, getOffsetHeight, getOffsetWidth, getStyleElement, getStyleName, getStyleName, getStylePrimaryName, getStylePrimaryName, isVisible, removeStyleDependentName, setElement, setStyleDependentName, setStyleName, setStyleName, setStyleName, setStylePrimaryName, setStylePrimaryName, setVisible, sinkBitlessEvent, unsinkEvents
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LayoutContainer

public LayoutContainer()
Creates a new layout container.


LayoutContainer

public LayoutContainer(Layout layout)
Creates a new layout container.

Parameters:
layout - the layout
Method Detail

add

public boolean add(com.google.gwt.user.client.ui.Widget widget)
Adds a widget to this Container. Fires the BeforeAdd event before adding, then fires the Add event after the component has been added.

Parameters:
widget - the widget to add. If the widget is not a Component instance it will be wrapped in a WidgetComponent

add

public boolean add(com.google.gwt.user.client.ui.Widget widget,
                   LayoutData layoutData)
Adds a widget to this Container. Fires the BeforeAdd event before adding, then fires the Add event after the component has been added.

Parameters:
widget - the widget to add. If the widget is not a Component instance it will be wrapped in a WidgetComponent
layoutData - the layout data

addText

public Html addText(java.lang.String text)
Creates a new HTML instance and adds it to the container. Fires the BeforeAdd event before adding, then fires the Add event after the component has been added.

Parameters:
text - the html text
Returns:
the new HTML instance

findComponent

public WidgetComponent findComponent(com.google.gwt.user.client.ui.Widget widget)
Returns the widget component that wraps the given widget.

Parameters:
widget - the wrapped widget
Returns:
the component or null

getLayout

public Layout getLayout()
Returns the layout which is associated with the container, or null if one has not been set.

Overrides:
getLayout in class Container<Component>
Returns:
the container's layout or null

getLayoutTarget

public El getLayoutTarget()
Override this method to specify the element to be used by the layout as the container. Allows the container to be decorated.

Overrides:
getLayoutTarget in class Container<Component>
Returns:
the element to be used as the panel's container

getWindowResizeDelay

public int getWindowResizeDelay()
Description copied from class: Component
Returns the window resize delay.

Overrides:
getWindowResizeDelay in class Component
Returns:
the delay

insert

public boolean insert(com.google.gwt.user.client.ui.Widget widget,
                      int index)
Inserts a widget into this Container at a specified index. Fires the BeforeAdd event before inserting, then fires the Add event after the component has been inserted.

Parameters:
widget - the widget to insert. If the widget is not a Component instance it will be wrapped in a WidgetComponent
index - the index at which the component will be inserted in

insert

public boolean insert(com.google.gwt.user.client.ui.Widget widget,
                      int index,
                      LayoutData layoutData)
Inserts a widget into this Container at a specified index. Fires the BeforeAdd event before inserting, then fires the Add event after the component has been inserted.

Parameters:
widget - the widget to insert. If the widget is not a Component instance it will be wrapped in a WidgetComponent
index - the index at which the component will be inserted in
layoutData - the component's layout data

isLayoutOnChange

public boolean isLayoutOnChange()
Returns true if the layout will be executed when widgets are added or removed.

Returns:
the layout on change state

isMonitorWindowResize

public boolean isMonitorWindowResize()
Description copied from class: Component
Returns true if browser resizing is monitored

Overrides:
isMonitorWindowResize in class Component
Returns:
true if window resize monitoring is enabled

layout

public boolean layout()
Description copied from class: Container
Executes the container's layout. If a layout has not been set a FlowLayout will be used.

Overrides:
layout in class Container<Component>
Returns:
true if layout was executed.

layout

public boolean layout(boolean force)
Description copied from class: Container
* Executes the container's layout. If a layout has not been set a FlowLayout will be used.

Overrides:
layout in class Container<Component>
Parameters:
force - true to force the layout call, also if caching things it is not needed
Returns:
true if layout was executed.

remove

public boolean remove(com.google.gwt.user.client.ui.Widget widget)
Removes a component from this container. Fires the 'BeforeRemove' event before removing, then fires the 'Remove' event after the component has been removed.

Parameters:
widget - the widget to remove

removeAll

public boolean removeAll()
Removes all of children from this container.

Overrides:
removeAll in class Container<Component>
Returns:
true if all items where removed

setLayout

public void setLayout(Layout layout)
Sets the container's layout.

Overrides:
setLayout in class Container<Component>
Parameters:
layout - the new layout

setLayoutData

public void setLayoutData(Component component,
                          LayoutData layoutData)
Sets the component's layout data.

Parameters:
component - the component
layoutData - the layout data

setLayoutOnChange

public void setLayoutOnChange(boolean layoutOnChange)
Specifies if the container's layout should be called when widgets are added or removed. Default value is false.

Overrides:
setLayoutOnChange in class Container<Component>
Parameters:
layoutOnChange - true to enable

setMonitorWindowResize

public void setMonitorWindowResize(boolean monitorWindowResize)
Description copied from class: Component
True to have onWindowResize executed when the browser window is resized (default to false). You need to override onWindowResize to get your needed functionality

Overrides:
setMonitorWindowResize in class Component
Parameters:
monitorWindowResize - true to monitor window resizing

setWindowResizeDelay

public void setWindowResizeDelay(int delay)
Description copied from class: Component
Sets delay in milliseconds used to buffer window resizing (defaults to 100).

Overrides:
setWindowResizeDelay in class Component
Parameters:
delay - the delay

onComponentEvent

public void onComponentEvent(ComponentEvent ce)
Description copied from class: Component
Any events a component receives will be forwarded to this method. Subclasses should override as needed. The Component.onBrowserEvent(com.google.gwt.user.client.Event) method should not be overridden or modified.

Overrides:
onComponentEvent in class ScrollContainer<Component>
Parameters:
ce - the base event

onFocus

protected void onFocus(ComponentEvent ce)

onBlur

protected void onBlur(ComponentEvent ce)

onRender

protected void onRender(com.google.gwt.user.client.Element parent,
                        int index)
Description copied from class: Component
Subclasses must override and ensure setElement is called for lazy rendered components.

Overrides:
onRender in class Component
Parameters:
parent - the target element
index - the insert location