public class

DialogBox

extends DecoratedPopupPanel
implements HasSafeHtml HasHTML MouseListener
java.lang.Object
   ↳ com.google.gwt.user.client.ui.UIObject
     ↳ com.google.gwt.user.client.ui.Widget
       ↳ com.google.gwt.user.client.ui.Panel
         ↳ com.google.gwt.user.client.ui.SimplePanel
           ↳ com.google.gwt.user.client.ui.PopupPanel
             ↳ com.google.gwt.user.client.ui.DecoratedPopupPanel
               ↳ com.google.gwt.user.client.ui.DialogBox

Class Overview

A form of popup that has a caption area at the top and can be dragged by the user. Unlike a PopupPanel, calls to setWidth(String) and setHeight(String) will set the width and height of the dialog box itself, even if a widget has not been added as yet.

CSS Style Rules

  • .gwt-DialogBox { the outside of the dialog }
  • .gwt-DialogBox .Caption { the caption }
  • .gwt-DialogBox .dialogContent { the wrapper around the content }
  • .gwt-DialogBox .dialogTopLeft { the top left cell }
  • .gwt-DialogBox .dialogTopLeftInner { the inner element of the cell }
  • .gwt-DialogBox .dialogTopCenter { the top center cell, where the caption is located }
  • .gwt-DialogBox .dialogTopCenterInner { the inner element of the cell }
  • .gwt-DialogBox .dialogTopRight { the top right cell }
  • .gwt-DialogBox .dialogTopRightInner { the inner element of the cell }
  • .gwt-DialogBox .dialogMiddleLeft { the middle left cell }
  • .gwt-DialogBox .dialogMiddleLeftInner { the inner element of the cell }
  • .gwt-DialogBox .dialogMiddleCenter { the middle center cell, where the content is located }
  • .gwt-DialogBox .dialogMiddleCenterInner { the inner element of the cell }
  • .gwt-DialogBox .dialogMiddleRight { the middle right cell }
  • .gwt-DialogBox .dialogMiddleRightInner { the inner element of the cell }
  • .gwt-DialogBox .dialogBottomLeft { the bottom left cell }
  • .gwt-DialogBox .dialogBottomLeftInner { the inner element of the cell }
  • .gwt-DialogBox .dialogBottomCenter { the bottom center cell }
  • .gwt-DialogBox .dialogBottomCenterInner { the inner element of the cell }
  • .gwt-DialogBox .dialogBottomRight { the bottom right cell }
  • .gwt-DialogBox .dialogBottomRightInner { the inner element of the cell }

Example

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

Use in UiBinder Templates

DialogBox elements in UiBinder templates can have one widget child and one <g:caption> child. (Note the lower case "c", meant to signal that the caption is not a runtime object, and so cannot have a ui:field attribute.) The body of the caption can be html.

For example:

 <g:DialogBox autoHide="true" modal="true">
   <g:caption><b>Caption text</b></g:caption>
   <g:HTMLPanel>
     Body text
     <g:Button ui:field='cancelButton'>Cancel</g:Button>
     <g:Button ui:field='okButton'>Okay</g:Button>
   </g:HTMLPanel>
 </g:DialogBox>
 

Summary

Nested Classes
interface DialogBox.Caption Set of characteristic interfaces supported by the DialogBox caption Note that this set might expand over time, so implement this interface at your own risk. 
[Expand]
Inherited Constants
From class com.google.gwt.user.client.ui.UIObject
Public Constructors
DialogBox()
Creates an empty dialog box.
DialogBox(boolean autoHide)
Creates an empty dialog box specifying its "auto-hide" property.
DialogBox(boolean autoHide, boolean modal)
Creates an empty dialog box specifying its "auto-hide" property.
Public Methods
final DialogBox.Caption getCaption()
Provides access to the dialog's caption.
String getHTML()
Gets this object's contents as HTML.
String getText()
Gets this object's text.
void hide()
Hides the popup and detaches it from the page.
void onBrowserEvent(Event event)
Fired whenever a browser event is received.
void onMouseDown(Widget sender, int x, int y)
This method is deprecated. Use beginDragging(MouseDownEvent) and getCaption() instead
void onMouseEnter(Widget sender)
This method is deprecated. Use addMouseOverHandler(MouseOverHandler) instead
void onMouseLeave(Widget sender)
This method is deprecated. Use addMouseOutHandler(MouseOutHandler) instead
void onMouseMove(Widget sender, int x, int y)
This method is deprecated. Use continueDragging(MouseMoveEvent) and getCaption() instead
void onMouseUp(Widget sender, int x, int y)
This method is deprecated. Use endDragging(MouseUpEvent) and getCaption() instead
void setHTML(SafeHtml html)
Sets the html string inside the caption.
void setHTML(String html)
Sets the html string inside the caption.
void setText(String text)
Sets the text inside the caption.
void show()
Shows the popup and attach it to the page.
Protected Methods
void beginDragging(MouseDownEvent event)
Called on mouse down in the caption area, begins the dragging loop by turning on event capture.
void continueDragging(MouseMoveEvent event)
Called on mouse move in the caption area, continues dragging if it was started by beginDragging(MouseDownEvent).
void doAttachChildren()
If a widget contains one or more child widgets that are not in the logical widget hierarchy (the child is physically connected only on the DOM level), it must override this method and call onAttach() for each of its child widgets.
void doDetachChildren()
If a widget contains one or more child widgets that are not in the logical widget hierarchy (the child is physically connected only on the DOM level), it must override this method and call onDetach() for each of its child widgets.
void endDragging(MouseUpEvent event)
Called on mouse up in the caption area, ends dragging by ending event capture.
void onEnsureDebugId(String baseID)
Affected Elements:
  • -caption = text at the top of the DialogBox.
void onPreviewNativeEvent(Event.NativePreviewEvent event)
[Expand]
Inherited Methods
From class com.google.gwt.user.client.ui.DecoratedPopupPanel
From class com.google.gwt.user.client.ui.PopupPanel
From class com.google.gwt.user.client.ui.SimplePanel
From class com.google.gwt.user.client.ui.Panel
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.logical.shared.HasCloseHandlers
From interface com.google.gwt.event.shared.HasHandlers
From interface com.google.gwt.safehtml.client.HasSafeHtml
From interface com.google.gwt.user.client.EventListener
From interface com.google.gwt.user.client.EventPreview
From interface com.google.gwt.user.client.ui.AcceptsOneWidget
From interface com.google.gwt.user.client.ui.HasAnimation
From interface com.google.gwt.user.client.ui.HasHTML
From interface com.google.gwt.user.client.ui.HasOneWidget
From interface com.google.gwt.user.client.ui.HasText
From interface com.google.gwt.user.client.ui.HasWidgets
From interface com.google.gwt.user.client.ui.HasWidgets.ForIsWidget
From interface com.google.gwt.user.client.ui.IsWidget
From interface com.google.gwt.user.client.ui.MouseListener
From interface com.google.gwt.user.client.ui.SourcesPopupEvents
From interface java.lang.Iterable

Public Constructors

public DialogBox ()

Creates an empty dialog box. It should not be shown until its child widget has been added using add(Widget).

public DialogBox (boolean autoHide)

Creates an empty dialog box specifying its "auto-hide" property. It should not be shown until its child widget has been added using add(Widget).

Parameters
autoHide true if the dialog should be automatically hidden when the user clicks outside of it

public DialogBox (boolean autoHide, boolean modal)

Creates an empty dialog box specifying its "auto-hide" property. It should not be shown until its child widget has been added using add(Widget).

Parameters
autoHide true if the dialog should be automatically hidden when the user clicks outside of it
modal true if keyboard and mouse events for widgets not contained by the dialog should be ignored

Public Methods

public final DialogBox.Caption getCaption ()

Provides access to the dialog's caption. This method is final because the Caption interface will expand. Therefore it is highly likely that subclasses which implemented this method would end up breaking.

Returns
  • the logical caption for this dialog box

public String getHTML ()

Gets this object's contents as HTML.

Returns
  • the object's HTML

public String getText ()

Gets this object's text.

Returns
  • the object's text

public void hide ()

Hides the popup and detaches it from the page. This has no effect if it is not currently showing.

public void onBrowserEvent (Event event)

Fired whenever a browser event is received.

Parameters
event the event received

public void onMouseDown (Widget sender, int x, int y)

This method is deprecated.
Use beginDragging(MouseDownEvent) and getCaption() instead

Fired when the user depresses the mouse button over a widget.

Parameters
sender the widget sending the event
x the x coordinate of the mouse
y the y coordinate of the mouse

public void onMouseEnter (Widget sender)

This method is deprecated.
Use addMouseOverHandler(MouseOverHandler) instead

Fired when the mouse enters a widget's area.

Parameters
sender the widget sending the event

public void onMouseLeave (Widget sender)

This method is deprecated.
Use addMouseOutHandler(MouseOutHandler) instead

Fired when the mouse leaves a widget's area.

Parameters
sender the widget sending the event

public void onMouseMove (Widget sender, int x, int y)

This method is deprecated.
Use continueDragging(MouseMoveEvent) and getCaption() instead

Fired when the user moves the mouse over a widget.

Parameters
sender the widget sending the event
x the x coordinate of the mouse
y the y coordinate of the mouse

public void onMouseUp (Widget sender, int x, int y)

This method is deprecated.
Use endDragging(MouseUpEvent) and getCaption() instead

Fired when the user releases the mouse button over a widget.

Parameters
sender the widget sending the event
x the x coordinate of the mouse
y the y coordinate of the mouse

public void setHTML (SafeHtml html)

Sets the html string inside the caption. Use setWidget(Widget) to set the contents inside the DialogBox.

Parameters
html the object's new HTML

public void setHTML (String html)

Sets the html string inside the caption. Use setWidget(Widget) to set the contents inside the DialogBox.

Parameters
html the object's new HTML

public void setText (String text)

Sets the text inside the caption. Use setWidget(Widget) to set the contents inside the DialogBox.

Parameters
text the object's new text

public void show ()

Shows the popup and attach it to the page. It must have a child widget before this method is called.

Protected Methods

protected void beginDragging (MouseDownEvent event)

Called on mouse down in the caption area, begins the dragging loop by turning on event capture.

Parameters
event the mouse down event that triggered dragging

protected void continueDragging (MouseMoveEvent event)

Called on mouse move in the caption area, continues dragging if it was started by beginDragging(MouseDownEvent).

Parameters
event the mouse move event that continues dragging

protected void doAttachChildren ()

If a widget contains one or more child widgets that are not in the logical widget hierarchy (the child is physically connected only on the DOM level), it must override this method and call onAttach() for each of its child widgets.

protected void doDetachChildren ()

If a widget contains one or more child widgets that are not in the logical widget hierarchy (the child is physically connected only on the DOM level), it must override this method and call onDetach() for each of its child widgets.

protected void endDragging (MouseUpEvent event)

Called on mouse up in the caption area, ends dragging by ending event capture.

Parameters
event the mouse up event that ended dragging

protected void onEnsureDebugId (String baseID)

Affected Elements:

  • -caption = text at the top of the DialogBox.
  • -content = the container around the content.

Parameters
baseID the base ID used by the main element

protected void onPreviewNativeEvent (Event.NativePreviewEvent event)