Class DialogBox

public class DialogBox
extends PopupPanel
implements HasHTML, MouseListener
A form of popup that has a caption area at the top and can be dragged by the user.

CSS Style Rules

Example

public class DialogBoxExample implements EntryPoint, ClickListener {

  private static class MyDialog extends DialogBox {

    public MyDialog() {
      // Set the dialog box's caption.
      setText("My First Dialog");

      // DialogBox is a SimplePanel, so you have to set its widget property to
      // whatever you want its contents to be.
      Button ok = new Button("OK");
      ok.addClickListener(new ClickListener() {
        public void onClick(Widget sender) {
          MyDialog.this.hide();
        }
      });
      setWidget(ok);
    }
  }

  public void onModuleLoad() {
    Button b = new Button("Click me");
    b.addClickListener(this);

    RootPanel.get().add(b);
  }

  public void onClick(Widget sender) {
    // Instantiate the dialog box and show it.
    new MyDialog().show();
  }
}

Constructors

DialogBox()Creates an empty dialog box.
DialogBox(boolean)Creates an empty dialog box specifying its "auto-hide" property.
DialogBox(boolean, boolean)Creates an empty dialog box specifying its "auto-hide" property.

Methods

getHTML()Gets this object's contents as HTML.
getText()Gets this object's text.
onEventPreview(Event)
onMouseDown(Widget, int, int)Fired when the user depresses the mouse button over a widget.
onMouseEnter(Widget)Fired when the mouse enters a widget's area.
onMouseLeave(Widget)Fired when the mouse leaves a widget's area.
onMouseMove(Widget, int, int)Fired when the user moves the mouse over a widget.
onMouseUp(Widget, int, int)Fired when the user releases the mouse button over a widget.
remove(Widget)
setHTML(String)Sets this object's contents via HTML.
setText(String)Sets this object's text.
setWidget(Widget)
setWidth(String)Override, so that interior panel reflows to match parent's new width.

Constructor Detail

DialogBox

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

DialogBox

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

DialogBox

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

Method Detail

getHTML

public String getHTML()
Gets this object's contents as HTML.

Return Value

the object's HTML

getText

public String getText()
Gets this object's text.

Return Value

the object's text

onEventPreview

public boolean onEventPreview(Event event)

Parameters

event

onMouseDown

public void onMouseDown(Widget sender, int x, int y)
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

onMouseEnter

public void onMouseEnter(Widget sender)
Fired when the mouse enters a widget's area.

Parameters

sender
the widget sending the event

onMouseLeave

public void onMouseLeave(Widget sender)
Fired when the mouse leaves a widget's area.

Parameters

sender
the widget sending the event

onMouseMove

public void onMouseMove(Widget sender, int x, int y)
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

onMouseUp

public void onMouseUp(Widget sender, int x, int y)
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

remove

public boolean remove(Widget w)

Parameters

w

setHTML

public void setHTML(String html)
Sets this object's contents via HTML. Use care when setting an object's HTML; it is an easy way to expose script-based security problems. Consider using setText(String) whenever possible.

Parameters

html
the object's new HTML

setText

public void setText(String text)
Sets this object's text.

Parameters

text
the object's new text

setWidget

public void setWidget(Widget w)

Parameters

w

setWidth

public void setWidth(String width)
Override, so that interior panel reflows to match parent's new width.

Parameters

width