Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.google.gwt.user.client.ui
Class DialogBox

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

All Implemented Interfaces:
  EventListener, EventPreview, HasHTML, HasText, HasWidgets, MouseListener, SourcesPopupEvents

    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

- .gwt-DialogBox { the outside of the dialog }
- .gwt-DialogBox .Caption { the caption }

### 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();
>       }
>     }

Nested Class Summary

Nested classes/interfaces inherited from class com.google.gwt.user.client.ui.PopupPanel
`PopupPanel.PositionCallback`

Constructor Summary
`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.

Method Summary
`java.lang.String` | `getHTML()` Gets this object's contents as HTML.
`java.lang.String` | `getText()` Gets this object's text.
`boolean` | `onEventPreview(Event event)` Called when a browser event occurs and this event preview is on top of the preview stack.
`void` | `onMouseDown(Widget sender, int x, int y)` Fired when the user depresses the mouse button over a widget.
`void` | `onMouseEnter(Widget sender)` Fired when the mouse enters a widget's area.
`void` | `onMouseLeave(Widget sender)` Fired when the mouse leaves a widget's area.
`void` | `onMouseMove(Widget sender, int x, int y)` Fired when the user moves the mouse over a widget.
`void` | `onMouseUp(Widget sender, int x, int y)` Fired when the user releases the mouse button over a widget.
`boolean` | `remove(Widget w)` Removes a child widget.
`void` | `setHTML(java.lang.String html)` Sets this object's contents via HTML.
`void` | `setText(java.lang.String text)` Sets this object's text.
`void` | `setWidget(Widget w)` Sets this panel's widget.
`void` | `setWidth(java.lang.String width)` Override, so that interior panel reflows to match parent's new width.

Methods inherited from class com.google.gwt.user.client.ui.PopupPanel
`addPopupListener, center, getContainerElement, getOffsetHeight, getOffsetWidth, getPopupLeft, getPopupTop, getStyleElement, getTitle, hide, onDetach, onKeyDownPreview, onKeyPressPreview, onKeyUpPreview, removePopupListener, setHeight, setPopupPosition, setPopupPositionAndShow, setTitle, setVisible, show`

Methods inherited from class com.google.gwt.user.client.ui.SimplePanel
`add, getWidget, iterator`

Methods inherited from class com.google.gwt.user.client.ui.Panel
`adopt, adopt, clear, disown, doAttachChildren, doDetachChildren, onLoad, onUnload, orphan`

Methods inherited from class com.google.gwt.user.client.ui.Widget
`getParent, isAttached, onAttach, onBrowserEvent, removeFromParent, setElement`

Methods inherited from class com.google.gwt.user.client.ui.UIObject
`addStyleDependentName, addStyleName, getAbsoluteLeft, getAbsoluteTop, getElement, getStyleName, getStyleName, getStylePrimaryName, getStylePrimaryName, isVisible, isVisible, removeStyleDependentName, removeStyleName, setPixelSize, setSize, setStyleName, setStyleName, setStyleName, setStylePrimaryName, setStylePrimaryName, setVisible, sinkEvents, toString, unsinkEvents`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Constructor Detail

### DialogBox

    public DialogBox()

  Creates an empty dialog box. It should not be shown until its child widget has been added using `SimplePanel.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 `SimplePanel.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 `SimplePanel.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 java.lang.String getHTML()

  Description copied from interface: `HasHTML`
  Gets this object's contents as HTML.

  Specified by:
    `getHTML` in interface `HasHTML`
  Returns:
    the object's HTML

### getText

    public java.lang.String getText()

  Description copied from interface: `HasText`
  Gets this object's text.

  Specified by:
    `getText` in interface `HasText`
  Returns:
    the object's text

### onEventPreview

    public boolean onEventPreview(Event event)

  Description copied from interface: `EventPreview`
  Called when a browser event occurs and this event preview is on top of the preview stack.

  Specified by:
    `onEventPreview` in interface `EventPreview`
  Overrides:
    `onEventPreview` in class `PopupPanel`
  Parameters:
    `event` - the browser event
  Returns:
    `false` to cancel the event
  See Also:
    `DOM.addEventPreview(EventPreview)`

### onMouseDown

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

  Description copied from interface: `MouseListener`
  Fired when the user depresses the mouse button over a widget.

  Specified by:
    `onMouseDown` in interface `MouseListener`
  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)

  Description copied from interface: `MouseListener`
  Fired when the mouse enters a widget's area.

  Specified by:
    `onMouseEnter` in interface `MouseListener`
  Parameters:
    `sender` - the widget sending the event

### onMouseLeave

    public void onMouseLeave(Widget sender)

  Description copied from interface: `MouseListener`
  Fired when the mouse leaves a widget's area.

  Specified by:
    `onMouseLeave` in interface `MouseListener`
  Parameters:
    `sender` - the widget sending the event

### onMouseMove

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

  Description copied from interface: `MouseListener`
  Fired when the user moves the mouse over a widget.

  Specified by:
    `onMouseMove` in interface `MouseListener`
  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)

  Description copied from interface: `MouseListener`
  Fired when the user releases the mouse button over a widget.

  Specified by:
    `onMouseUp` in interface `MouseListener`
  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)

  Description copied from class: `Panel`
  Removes a child widget.

  How to Override this Method

  There are several important things that must take place in the correct order to properly remove a Widget from a Panel. Not all of these steps will be relevant to every Panel, but all of the steps must be considered.

  1. Validate: Make sure this Panel is actually the parent of the child Widget; return `false` if it is not.
  2. Orphan: Call `Panel.orphan(Widget)` first while the child Widget is still attached.
  3. Physical Detach: Adjust the DOM to account for the removal of the child Widget. The Widget's Element must be physically removed from the DOM.
  4. Logical Detach: Update the Panel's state variables to reflect the removal of the child Widget. Example: the Widget is removed from the Panel's `WidgetCollection`.

  Specified by:
    `remove` in interface `HasWidgets`
  Overrides:
    `remove` in class `SimplePanel`
  Parameters:
    `w` - the widget to be removed
  Returns:
    `true` if the child was present

### setHTML

    public void setHTML(java.lang.String html)

  Description copied from interface: `HasHTML`
  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 `HasText.setText(String)` whenever possible.

  Specified by:
    `setHTML` in interface `HasHTML`
  Parameters:
    `html` - the object's new HTML

### setText

    public void setText(java.lang.String text)

  Description copied from interface: `HasText`
  Sets this object's text.

  Specified by:
    `setText` in interface `HasText`
  Parameters:
    `text` - the object's new text

### setWidget

    public void setWidget(Widget w)

  Description copied from class: `SimplePanel`
  Sets this panel's widget. Any existing child widget will be removed.

  Overrides:
    `setWidget` in class `PopupPanel`
  Parameters:
    `w` - the panel's new widget, or `null` to clear the panel

### setWidth

    public void setWidth(java.lang.String width)

  Override, so that interior panel reflows to match parent's new width.

  Overrides:
    `setWidth` in class `PopupPanel`
  Parameters:
    `width` - the object's new width, in CSS units (e.g. "10px", "1em")

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD