GWT - Widget Class

Advertisements


Introduction

The class Widget is the base class for the majority of user-interface objects. Widget adds support for receiving events from the browser and being added directly to panels.

Class declaration

Following is the declaration for com.google.gwt.user.client.ui.Widget class:

public class Widget
   extends UIObject
      implements EventListener

Field

Following are the fields for com.google.gwt.user.client.ui.Widget class:

  • public static final java.lang.String DEBUG_ID_PREFIX -- The element ID that you specify will be prefixed by the static string DEBUG_ID_PREFIX.

Class constructors

S.N.Constructor & Description
1Widget()
This creates a Widget for the child classes.

Class methods

S.N.Method & Description
1protected <H extends EventHandler> HandlerRegistration addDomHandler(H handler, DomEvent.Type<H> type)
Adds a native event handler to the widget and sinks the corresponding native event.
2protected <H extends EventHandler> HandlerRegistration addHandler(H handler, GwtEvent.Type<H> type)
Adds this handler to the widget.
3protected void delegateEvent(Widget target, GwtEvent<?> event)
Fires an event on a child widget.
4protected void doAttachChildren()
If a widget implements HasWidgets, it must override this method and call onAttach() for each of its child widgets.
5protected void doDetachChildren()
If a widget implements HasWidgets, it must override this method and call onDetach() for each of its child widgets.
6void fireEvent(GwtEvent<?> event)
Fires the given event to all the appropriate handlers.
7protected int getHandlerCount(GwtEvent.Type<?> type)
Gets the number of handlers listening to the event type.
8Widget getParent()
Gets this widget's parent panel.
9boolean 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).
10protected boolean isOrWasAttached()
Has this widget ever been attached?
11protected void onAttach()
This method is called when a widget is attached to the browser's document.
12void onBrowserEvent(Event event)
Fired whenever a browser event is received.
13protected void onDetach()
This method is called when a widget is detached from the browser's document.
14protected void onLoad()
Gets a handle to the object's underlying DOM element.
15protected void onUnload()
This method is called immediately before a widget will be detached from the browser's document.
16void removeFromParent()
Removes this widget from its parent widget.
17void sinkEvents(int eventBitsToAdd)
Overridden to defer the call to super.sinkEvents until the first time this widget is attached to the dom, as a performance enhancement.

Methods inherited

This class inherits methods from the following classes:

  • com.google.gwt.user.client.ui.UIObject



Advertisements
Advertisements