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.Label
com.google.gwt.user.client.ui.HTML
- All Implemented Interfaces:
- HasAllMouseHandlers, HasClickHandlers, HasMouseDownHandlers, HasMouseMoveHandlers, HasMouseOutHandlers, HasMouseOverHandlers, HasMouseUpHandlers, HasMouseWheelHandlers, HasHandlers, HasDirection, EventListener, HasHorizontalAlignment, HasHTML, HasText, HasWordWrap, SourcesClickEvents, SourcesMouseEvents
- Direct Known Subclasses:
- InlineHTML
public class HTML
- extends Label
- implements HasHTML
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.
CSS Style Rules
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 = new HTML(
"This is HTML. It will be interpreted as such if you specify "
+ "the asHTML flag.", true);
// Add them to the root panel.
VerticalPanel panel = new VerticalPanel();
panel.add(lbl);
panel.add(html);
RootPanel.get().add(panel);
}
}
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(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. |
Method Summary |
java.lang.String |
getHTML()
Gets this object's contents as HTML. |
void |
setHTML(java.lang.String html)
Sets this object's contents via HTML. |
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, addMouseDownHandler, addMouseListener, addMouseMoveHandler, addMouseOutHandler, addMouseOverHandler, addMouseUpHandler, addMouseWheelHandler, addMouseWheelListener, getDirection, getHorizontalAlignment, getText, getWordWrap, removeClickListener, removeMouseListener, removeMouseWheelListener, setDirection, setHorizontalAlignment, setText, setWordWrap |
Methods inherited from class com.google.gwt.user.client.ui.Widget |
addDomHandler, addHandler, delegateEvent, doAttachChildren, doDetachChildren, fireEvent, getHandlerCount, getLayoutData, getParent, isAttached, isOrWasAttached, onAttach, onBrowserEvent, onDetach, onLoad, onUnload, removeFromParent, setLayoutData, sinkEvents |
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, setElement, setElement, setHeight, setPixelSize, setSize, setStyleName, setStyleName, setStyleName, setStylePrimaryName, setStylePrimaryName, setTitle, setVisible, setVisible, setWidth, toString, unsinkEvents |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
HTML
public HTML()
- Creates an empty HTML widget.
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,
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 contentswordWrap
- 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
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)
- 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