Google Web Toolkit (Beta)
Search this site:

# Class DelegatingChangeListenerCollection

public class DelegatingChangeListenerCollection
extends ChangeListenerCollection
implements ChangeListener
ChangeListenerCollection used to correctly hook up listeners which need to listen to events from another source.

For example, Composite widgets often need to listen to events generated on their wrapped widget. Upon the firing of a wrapped widget's event, the composite widget must fire its own listeners with itself as the source of the event. To use a DelegatingChangeListenerCollection, simply use the DelegatingChangeListenerCollection instead of a ChangeListenerCollection. For example, in SuggestBox, the following code is used to listen to change events on the SuggestBox's underlying widget.

      public void addChangeListener(ChangeListener listener) {
        if (changeListeners == null) {
          changeListeners = new DelegatingChangeListenerCollection(this, box);
        }
        changeListeners.add(listener);
      }

## Constructors

DelegatingChangeListenerCollection(Widget, SourcesChangeEvents) | Constructor for DelegatingChangeListenerCollection.

## Methods

onChange(Widget) | Fired when a widget changes, where 'change' is defined by the widget sending the event.

## Constructor Detail

### DelegatingChangeListenerCollection

public DelegatingChangeListenerCollection(Widget owner, SourcesChangeEvents delegatedTo)
Constructor for DelegatingChangeListenerCollection.

#### Parameters

owner
  owner of listeners
delegatedTo
  source of events

## Method Detail

### onChange

public void onChange(Widget sender)
Fired when a widget changes, where 'change' is defined by the widget sending the event.

#### Parameters

sender
  the widget that has changed.