public abstract class

Composite

extends Widget
java.lang.Object
   ↳ com.google.gwt.user.client.ui.UIObject
     ↳ com.google.gwt.user.client.ui.Widget
       ↳ com.google.gwt.user.client.ui.Composite
Known Direct Subclasses
Known Indirect Subclasses

Class Overview

A type of widget that can wrap another widget, hiding the wrapped widget's methods. When added to a panel, a composite behaves exactly as if the widget it wraps had been added.

The composite is useful for creating a single widget out of an aggregate of multiple other widgets contained in a single panel.

Example

{@example com.google.gwt.examples.CompositeExample}

Summary

[Expand]
Inherited Constants
From class com.google.gwt.user.client.ui.UIObject
Public Constructors
Composite()
Public Methods
boolean isAttached()
Determines whether this widget is currently attached to the browser's document (i.e., there is an unbroken chain of widgets between this widget and the underlying browser document).
void onBrowserEvent(Event event)
Fired whenever a browser event is received.
Protected Methods
Widget getWidget()
Provides subclasses access to the topmost widget that defines this composite.
void initWidget(Widget widget)
Sets the widget to be wrapped by the composite.
void onAttach()

This method is called when a widget is attached to the browser's document.

void onDetach()

This method is called when a widget is detached from the browser's document.

void setWidget(Widget widget)
This method is deprecated. Use initWidget(Widget) instead
[Expand]
Inherited Methods
From class com.google.gwt.user.client.ui.Widget
From class com.google.gwt.user.client.ui.UIObject
From class java.lang.Object
From interface com.google.gwt.event.logical.shared.HasAttachHandlers
From interface com.google.gwt.event.shared.HasHandlers
From interface com.google.gwt.user.client.EventListener
From interface com.google.gwt.user.client.ui.IsWidget

Public Constructors

public Composite ()

Public Methods

public boolean isAttached ()

Determines whether this widget is currently attached to the browser's document (i.e., there is an unbroken chain of widgets between this widget and the underlying browser document).

Returns
  • true if the widget is attached

public void onBrowserEvent (Event event)

Fired whenever a browser event is received.

Parameters
event the event received

Protected Methods

protected Widget getWidget ()

Provides subclasses access to the topmost widget that defines this composite.

Returns
  • the widget

protected void initWidget (Widget widget)

Sets the widget to be wrapped by the composite. The wrapped widget must be set before calling any Widget methods on this object, or adding it to a panel. This method may only be called once for a given composite.

Parameters
widget the widget to be wrapped

protected void onAttach ()

This method is called when a widget is attached to the browser's document. To receive notification after a Widget has been added to the document, override the onLoad() method or use addAttachHandler(AttachEvent.Handler).

It is strongly recommended that you override onLoad() or doAttachChildren() instead of this method to avoid inconsistencies between logical and physical attachment states.

Subclasses that override this method must call super.onAttach() to ensure that the Widget has been attached to its underlying Element.

protected void onDetach ()

This method is called when a widget is detached from the browser's document. To receive notification before a Widget is removed from the document, override the onUnload() method or use addAttachHandler(AttachEvent.Handler).

It is strongly recommended that you override onUnload() or doDetachChildren() instead of this method to avoid inconsistencies between logical and physical attachment states.

Subclasses that override this method must call super.onDetach() to ensure that the Widget has been detached from the underlying Element. Failure to do so will result in application memory leaks due to circular references between DOM Elements and JavaScript objects.

protected void setWidget (Widget widget)

This method is deprecated.
Use initWidget(Widget) instead

This method was for initializing the Widget to be wrapped by this Composite, but has been deprecated in favor of initWidget(Widget).