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

Sr.No. Constructor & Description
1

Widget()

This creates a Widget for the child classes.

Class Methods

Sr.No. Method & Description
1

protected <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.

2

protected <H extends EventHandler> HandlerRegistration addHandler(H handler, GwtEvent.Type<H> type)

Adds this handler to the widget.

3

protected void delegateEvent(Widget target, GwtEvent<?> event)

Fires an event on a child widget.

4

protected void doAttachChildren()

If a widget implements HasWidgets, it must override this method and call onAttach() for each of its child widgets.

5

protected void doDetachChildren()

If a widget implements HasWidgets, it must override this method and call onDetach() for each of its child widgets.

6

void fireEvent(GwtEvent<?> event)

Fires the given event to all the appropriate handlers.

7

protected int getHandlerCount(GwtEvent.Type<?> type)

Gets the number of handlers listening to the event type.

8

Widget getParent()

Gets this widget's parent panel.

9

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).

10

protected boolean isOrWasAttached()

Has this widget ever been attached?

11

protected void onAttach()

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

12

void onBrowserEvent(Event event)

Fired whenever a browser event is received.

13

protected void onDetach()

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

14

protected void onLoad()

Gets a handle to the object's underlying DOM element.

15

protected void onUnload()

This method is called immediately before a widget will be detached from the browser's document.

16

void removeFromParent()

Removes this widget from its parent widget.

17

void 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

gwt_basic_widgets.htm
Advertisements