Overview | Package | Class | Use | Deprecated | Help
| GWT 2.7.0
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

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

    java.lang.Object
      com.google.gwt.user.client.ui.UIObject
          com.google.gwt.user.client.ui.Widget
              com.google.gwt.user.client.ui.LabelBase<java.lang.String>
                  com.google.gwt.user.client.ui.Label
                      com.google.gwt.user.client.ui.HTML

All Implemented Interfaces:
  IsEditor<LeafValueEditor<java.lang.String>>, HasAllDragAndDropHandlers, HasAllGestureHandlers, HasAllMouseHandlers, HasAllTouchHandlers, HasClickHandlers, HasDoubleClickHandlers, HasDragEndHandlers, HasDragEnterHandlers, HasDragHandlers, HasDragLeaveHandlers, HasDragOverHandlers, HasDragStartHandlers, HasDropHandlers, HasGestureChangeHandlers, HasGestureEndHandlers, HasGestureStartHandlers, HasMouseDownHandlers, HasMouseMoveHandlers, HasMouseOutHandlers, HasMouseOverHandlers, HasMouseUpHandlers, HasMouseWheelHandlers, HasTouchCancelHandlers, HasTouchEndHandlers, HasTouchMoveHandlers, HasTouchStartHandlers, HasAttachHandlers, HasHandlers, HasDirection, HasDirectionEstimator, HasSafeHtml, EventListener, HasAutoHorizontalAlignment, HasDirectionalHtml, HasDirectionalSafeHtml, HasDirectionalText, HasHorizontalAlignment, HasHTML, HasText, HasVisibility, HasWordWrap, IsWidget, SourcesClickEvents, SourcesMouseEvents

Direct Known Subclasses:
  DialogBox.CaptionImpl, InlineHTML

    public class HTML

extends Label
implements HasDirectionalHtml, HasDirectionalSafeHtml

A widget that can contain arbitrary HTML. This widget uses a <div> element, causing it to be displayed with block layout.

If you only need a simple label (text, but not HTML), then the `Label` widget is more appropriate, as it disallows the use of HTML, which can lead to potential security issues if not used properly.

### Built-in Bidi Text Support

This widget is capable of automatically adjusting its direction according to its content. This feature is controlled by `LabelBase.setDirectionEstimator(boolean)` or passing a DirectionEstimator parameter to the constructor, and is off by default.

### CSS Style Rules

- .gwt-HTML { }

### Example

>     public class HTMLExample implements EntryPoint {

>       public void onModuleLoad() {
>         // Create a Label and an HTML widget.
>         Label lbl = new Label("This is just text.  It will not be interpreted "
>           + "as <html>.");

>         HTML html = new HTML(
>           "This is <b>HTML</b>.  It will be interpreted as such if you specify "
>             + "the <span style='font-family:fixed'>asHTML</span> flag.", true);

>         // Add them to the root panel.
>         VerticalPanel panel = new VerticalPanel();
>         panel.add(lbl);
>         panel.add(html);
>         RootPanel.get().add(panel);
>       }
>     }

Nested Class Summary

Nested classes/interfaces inherited from class com.google.gwt.user.client.ui.UIObject
`UIObject.DebugIdImpl, UIObject.DebugIdImplEnabled`

Nested classes/interfaces inherited from interface com.google.gwt.i18n.client.HasDirection
`HasDirection.Direction`

Nested classes/interfaces inherited from interface com.google.gwt.user.client.ui.HasHorizontalAlignment
`HasHorizontalAlignment.AutoHorizontalAlignmentConstant, HasHorizontalAlignment.HorizontalAlignmentConstant`

Field Summary

Fields inherited from class com.google.gwt.user.client.ui.Label
`DEFAULT_DIRECTION_ESTIMATOR`

Fields inherited from class com.google.gwt.user.client.ui.LabelBase
`directionalTextHelper`

Fields inherited from class com.google.gwt.user.client.ui.Widget
`eventsToSink`

Fields inherited from class com.google.gwt.user.client.ui.UIObject
`DEBUG_ID_PREFIX, MISSING_ELEMENT_ERROR, SETELEMENT_TWICE_ERROR`

Fields inherited from interface com.google.gwt.user.client.ui.HasAutoHorizontalAlignment
`ALIGN_CONTENT_END, ALIGN_CONTENT_START`

Fields inherited from interface com.google.gwt.user.client.ui.HasHorizontalAlignment
`ALIGN_CENTER, ALIGN_DEFAULT, ALIGN_JUSTIFY, ALIGN_LEFT, ALIGN_LOCALE_END, ALIGN_LOCALE_START, ALIGN_RIGHT`

Constructor Summary
`` | `HTML()` Creates an empty HTML widget.
`protected` | `HTML(Element element)` This constructor may be used by subclasses to explicitly use an existing element.
`` | `HTML(SafeHtml html)` Initializes the widget's HTML from a given `SafeHtml` object.
`` | `HTML(SafeHtml html, DirectionEstimator directionEstimator)` Creates an HTML widget with the specified HTML contents and specifies a direction estimator.
`` | `HTML(SafeHtml html, HasDirection.Direction dir)` Creates an HTML widget with the specified contents and with the specified direction.
`` | `HTML(java.lang.String html)` Creates an HTML widget with the specified HTML contents.
`` | `HTML(java.lang.String html, boolean wordWrap)` Creates an HTML widget with the specified contents, optionally treating it as HTML, and optionally disabling word wrapping.
`` | `HTML(java.lang.String html, HasDirection.Direction dir)` Creates an HTML widget with the specified HTML contents and with the specified direction.

Method Summary
`java.lang.String` | `getHTML()` Gets this object's contents as HTML.
`protected java.lang.String` | `getTextOrHtml(boolean isHtml)`
`void` | `setHTML(SafeHtml html)` Sets this object's contents via known-safe HTML.
`void` | `setHTML(SafeHtml html, HasDirection.Direction dir)` Sets this object's html, also declaring its direction.
`void` | `setHTML(java.lang.String html)` Sets the label's content to the given HTML.
`void` | `setHTML(java.lang.String html, HasDirection.Direction dir)` Sets the label's content to the given HTML, applying the given direction.
`static HTML` | `wrap(Element element)` Creates an HTML widget that wraps an existing <div> or <span> element.

Methods inherited from class com.google.gwt.user.client.ui.Label
`addClickHandler, addClickListener, addDoubleClickHandler, addDragEndHandler, addDragEnterHandler, addDragHandler, addDragLeaveHandler, addDragOverHandler, addDragStartHandler, addDropHandler, addGestureChangeHandler, addGestureEndHandler, addGestureStartHandler, addMouseDownHandler, addMouseListener, addMouseMoveHandler, addMouseOutHandler, addMouseOverHandler, addMouseUpHandler, addMouseWheelHandler, addMouseWheelListener, addTouchCancelHandler, addTouchEndHandler, addTouchMoveHandler, addTouchStartHandler, asEditor, getDirection, getText, getTextDirection, removeClickListener, removeMouseListener, removeMouseWheelListener, setDirection, setText, setText`

Methods inherited from class com.google.gwt.user.client.ui.LabelBase
`getAutoHorizontalAlignment, getDirectionEstimator, getHorizontalAlignment, getWordWrap, setAutoHorizontalAlignment, setDirectionEstimator, setDirectionEstimator, setHorizontalAlignment, setWordWrap, updateHorizontalAlignment`

Methods inherited from class com.google.gwt.user.client.ui.Widget
`addAttachHandler, addBitlessDomHandler, addDomHandler, addHandler, asWidget, asWidgetOrNull, createHandlerManager, delegateEvent, doAttachChildren, doDetachChildren, ensureHandlers, fireEvent, getHandlerCount, getHandlerManager, getLayoutData, getParent, isAttached, isOrWasAttached, onAttach, onBrowserEvent, onDetach, onLoad, onUnload, removeFromParent, replaceElement, setLayoutData, setParent, sinkEvents, unsinkEvents`

Methods inherited from class com.google.gwt.user.client.ui.UIObject
`addStyleDependentName, addStyleName, ensureDebugId, ensureDebugId, ensureDebugId, getAbsoluteLeft, getAbsoluteTop, getElement, getOffsetHeight, getOffsetWidth, getStyleElement, getStyleName, getStyleName, getStylePrimaryName, getStylePrimaryName, getTitle, isVisible, isVisible, onEnsureDebugId, removeStyleDependentName, removeStyleName, resolvePotentialElement, setElement, setElement, setHeight, setPixelSize, setSize, setStyleDependentName, setStyleName, setStyleName, setStyleName, setStyleName, setStylePrimaryName, setStylePrimaryName, setTitle, setVisible, setVisible, setWidth, sinkBitlessEvent, toString`

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

Methods inherited from interface com.google.gwt.user.client.ui.HasDirectionalText
`getTextDirection, setText`

Methods inherited from interface com.google.gwt.user.client.ui.HasText
`getText, setText`

Methods inherited from interface com.google.gwt.event.shared.HasHandlers
`fireEvent`

Constructor Detail

### HTML

    public HTML()

  Creates an empty HTML widget.

### HTML

    public HTML(SafeHtml html)

  Initializes the widget's HTML from a given `SafeHtml` object.

  Parameters:
    `html` - the new widget's HTML contents

### HTML

    public HTML(SafeHtml html,
                HasDirection.Direction dir)

  Creates an HTML widget with the specified contents and with the specified direction.

  Parameters:
    `html` - the new widget's SafeHtml contents
    `dir` - the content's direction. Note: `Direction.DEFAULT` means direction should be inherited from the widget's parent element.

### HTML

    public HTML(SafeHtml html,
                DirectionEstimator directionEstimator)

  Creates an HTML widget with the specified HTML contents and specifies a direction estimator.

  Parameters:
    `html` - the new widget's SafeHtml contents
    `directionEstimator` - A DirectionEstimator object used for automatic direction adjustment. For convenience, `Label.DEFAULT_DIRECTION_ESTIMATOR` can be used.

### HTML

    public HTML(java.lang.String html)

  Creates an HTML widget with the specified HTML contents.

  Parameters:
    `html` - the new widget's HTML contents

### HTML

    public HTML(java.lang.String html,
                HasDirection.Direction dir)

  Creates an HTML widget with the specified HTML contents and with the specified direction.

  Parameters:
    `html` - the new widget's HTML contents
    `dir` - the content's direction. Note: `Direction.DEFAULT` means direction should be inherited from the widget's parent element.

### HTML

    public HTML(java.lang.String html,
                boolean wordWrap)

  Creates an HTML widget with the specified contents, optionally treating it as HTML, and optionally disabling word wrapping.

  Parameters:
    `html` - the widget's contents
    `wordWrap` - `false` to disable word wrapping

### HTML

    protected HTML(Element element)

  This constructor may be used by subclasses to explicitly use an existing element. This element must be either a <div> or <span> element.

  Parameters:
    `element` - the element to be used

Method Detail

### wrap

    public static HTML wrap(Element element)

  Creates an HTML widget that wraps an existing <div> or <span> element. This element must already be attached to the document. If the element is removed from the document, you must call `RootPanel.detachNow(Widget)`.

  Parameters:
    `element` - the element to be wrapped

### 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

### setHTML

    public void setHTML(java.lang.String html)

  Sets the label's content to the given HTML. See `Label.setText(String)` for details on potential effects on direction and alignment.

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

### setHTML

    public void setHTML(java.lang.String html,
                        HasDirection.Direction dir)

  Sets the label's content to the given HTML, applying the given direction. See `setText(String, Direction)` for details on potential effects on alignment.

  Specified by:
    `setHTML` in interface `HasDirectionalHtml`
  Parameters:
    `html` - the new widget's HTML content
    `dir` - the content's direction. Note: `Direction.DEFAULT` means direction should be inherited from the widget's parent element.

### setHTML

    public void setHTML(SafeHtml html)

  Sets this object's contents via known-safe HTML.

  Specified by:
    `setHTML` in interface `HasSafeHtml`
  Parameters:
    `html` - the html to set.
  See Also:
    `HasSafeHtml.setHTML(SafeHtml)`

### setHTML

    public void setHTML(SafeHtml html,
                        HasDirection.Direction dir)

  Description copied from interface: `HasDirectionalSafeHtml`
  Sets this object's html, also declaring its direction.

  Specified by:
    `setHTML` in interface `HasDirectionalSafeHtml`
  Parameters:
    `html` - the object's new html
    `dir` - the html's direction

### getTextOrHtml

    protected java.lang.String getTextOrHtml(boolean isHtml)

Overview | Package | Class | Use | Deprecated | Help
| GWT 2.7.0
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD