Class Label
A widget that contains arbitrary text,
not interpreted as HTML.
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 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);
}
}
Constructors
Methods
Constructor Detail
Label
public Label()
Creates an empty label.
Label
Creates a label with the specified text.
Parameters
- text
- the new label's text
Label
public
Label(
String text, boolean wordWrap)
Creates a label with the specified text.
Parameters
- text
- the new label's text
- wordWrap
-
false
to disable word wrapping
Method Detail
addClickListener
Adds a listener interface to receive click events.
Parameters
- listener
- the listener interface to add
addMouseListener
Adds a listener interface to receive mouse events.
Parameters
- listener
- the listener interface to add
addMouseWheelListener
Adds a listener interface to receive mouse events.
Parameters
- listener
- the listener interface to add
getHorizontalAlignment
Gets the horizontal alignment.
Return Value
the current horizontal alignment.
getText
Gets this object's text.
Return Value
the object's text
getWordWrap
public boolean getWordWrap()
Gets whether word-wrapping is enabled.
Return Value
true
if word-wrapping is enabled.
onBrowserEvent
public void
onBrowserEvent(
Event event)
Parameters
- event
-
removeClickListener
Removes a previously added listener interface.
Parameters
- listener
- the listener interface to remove
removeMouseListener
Removes a previously added listener interface.
Parameters
- listener
- the listener interface to remove
removeMouseWheelListener
Removes a previously added listener interface.
Parameters
- listener
- the listener interface to remove
setHorizontalAlignment
Sets the horizontal alignment.
Parameters
- align
- the horizontal alignment (
HasHorizontalAlignment.ALIGN_LEFT,
HasHorizontalAlignment.ALIGN_CENTER, or
HasHorizontalAlignment.ALIGN_RIGHT).
setText
public void
setText(
String text)
Sets this object's text.
Parameters
- text
- the object's new text
setWordWrap
public void setWordWrap(boolean wrap)
Sets whether word-wrapping is enabled.
Parameters
- wrap
-
true
to enable word-wrapping.