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 it's widget property to
      // whatever you want its contents to be.
      setWidget(new Label("Click outside of this popup to close it"));
    }
  }

  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.

Methods

add(Widget)
getHTML()Gets this object's contents as HTML.
getText()Gets this object's text.
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 enters 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.

Constructor Detail

DialogBox

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

Method Detail

add

public boolean add(Widget w)

Parameters

w

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

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 enters 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 whenever possible.

Parameters

html
the object's new HTML

setText

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

Parameters

text