Class WLabel
The label may contain an image and/or text. It acts like a proxy for giving focus to a WFormWidget
. When both an image and text are specified, the image is put to the left of the
text.
Usage example:
WContainerWidget w = new WContainerWidget();
WLabel label = new WLabel("Favourite Actress: ", w);
WLineEdit edit = new WLineEdit("Renee Zellweger", w);
label.setBuddy(edit);
The widget corresponds to the HTML <label>
tag. When no buddy is set, it is
rendered using an HTML <span>
or <div>
to avoid click event
handling misbehavior on Microsoft Internet Explorer.
WLabel is an inline
widget.
CSS
This widget does not provide styling, and can be styled using inline or external CSS as
appropriate. A label's text may be styled via a nested <span>
element,
and it's image may be styled via a nested <img>
element.
-
Nested Class Summary
Nested classes/interfaces inherited from class eu.webtoolkit.jwt.WObject
WObject.FormData
-
Field Summary
Fields inherited from class eu.webtoolkit.jwt.WInteractWidget
dragTouchEndSlot_, dragTouchSlot_
-
Constructor Summary
ConstructorDescriptionWLabel()
Creates a label with empty text and optional parent.WLabel
(WContainerWidget parentContainer) Creates a label with empty text and optional parent.Creates a label with an image.WLabel
(WImage image, WContainerWidget parentContainer) Creates a label with an image.WLabel
(CharSequence text) Creates a label with a given text.WLabel
(CharSequence text, WContainerWidget parentContainer) Creates a label with a given text. -
Method Summary
Modifier and TypeMethodDescriptiongetBuddy()
Returns the buddy of this label.protected void
getDomChanges
(List<DomElement> result, WApplication app) Get DOM changes for this widget.getImage()
Returns the image.getText()
Returns the label text.Returns the text format.boolean
Returns whether word wrapping is on.protected void
iterateChildren
(HandleWidgetMethod method) protected void
propagateSetEnabled
(boolean enabled) Propagates that a widget was enabled or disabled through children.void
remove()
Destructor.void
setBuddy
(WFormWidget buddy) Sets the buddy of this label.final void
Sets the image.void
Sets the image.void
setText
(CharSequence text) Sets the label text.boolean
setTextFormat
(TextFormat format) Sets the text format.void
setWordWrap
(boolean wordWrap) Configures word wrapping.protected void
updateImage
(DomElement element, boolean all, WApplication app, int pos) protected void
updateText
(DomElement element, boolean all, WApplication app, int pos) Methods inherited from class eu.webtoolkit.jwt.WInteractWidget
clicked, doubleClicked, enterPressed, escapePressed, gestureChanged, gestureEnded, gestureStarted, getMouseOverDelay, isEnabled, keyPressed, keyWentDown, keyWentUp, load, mouseDragged, mouseMoved, mouseWentDown, mouseWentOut, mouseWentOver, mouseWentUp, mouseWheel, setDraggable, setDraggable, setDraggable, setDraggable, setMouseOverDelay, setPopup, touchEnded, touchMoved, touchStarted, unsetDraggable
Methods inherited from class eu.webtoolkit.jwt.WWebWidget
addStyleClass, beingDeleted, blurred, callJavaScriptMember, childrenChanged, createDomElement, doJavaScript, enableAjax, escapeText, escapeText, escapeText, escapeText, find, findById, focussed, getAttributeValue, getBaseZIndex, getChildren, getClearSides, getDecorationStyle, getFloatSide, getHeight, getHtmlTagName, getId, getJavaScriptMember, getLineHeight, getMargin, getMaximumHeight, getMaximumWidth, getMinimumHeight, getMinimumWidth, getOffset, getPositionScheme, getScrollVisibilityMargin, getStyleClass, getTabIndex, getToolTip, getVerticalAlignment, getVerticalAlignmentLength, getWidth, hasFocus, hasStyleClass, isCanReceiveFocus, isDisabled, isHidden, isHiddenKeepsGeometry, isInline, isLoaded, isPopup, isRendered, isScrollVisibilityEnabled, isScrollVisible, isSetFirstFocus, isThemeStyleEnabled, isVisible, jsStringLiteral, jsStringLiteral, manageWidget, parentResized, parentResized, propagateSetVisible, refresh, removeScript, removeStyleClass, render, resize, scrollVisibilityChanged, setAttributeValue, setBaseZIndex, setCanReceiveFocus, setClearSides, setDecorationStyle, setDeferredToolTip, setDisabled, setFlexBox, setFloatSide, setFocus, setHidden, setHiddenKeepsGeometry, setHtmlTagName, setId, setInline, setJavaScriptMember, setLineHeight, setLoadLaterWhenInvisible, setMargin, setMaximumSize, setMinimumSize, setObjectName, setOffsets, setParentWidget, setPositionScheme, setScrollVisibilityEnabled, setScrollVisibilityMargin, setSelectable, setStyleClass, setTabIndex, setThemeStyleEnabled, setToolTip, setVerticalAlignment, unescapeText, updateSignalConnection, voidEventSignal, widgetAdded, widgetRemoved
Methods inherited from class eu.webtoolkit.jwt.WWidget
acceptDrops, acceptDrops, addCssRule, addCssRule, addJSignal, addStyleClass, animateHide, animateShow, boxBorder, boxPadding, createJavaScript, disable, dropEvent, enable, getDropTouch, getJsRef, getParent, hide, htmlText, isExposed, isGlobalWidget, isLayoutSizeAware, layoutSizeChanged, needsRerender, positionAt, positionAt, removeFromParent, removeStyleClass, removeWidget, render, resize, scheduleRender, scheduleRender, scheduleRender, setClearSides, setDeferredToolTip, setFocus, setHeight, setHidden, setLayoutSizeAware, setMargin, setMargin, setMargin, setMargin, setMargin, setOffsets, setOffsets, setOffsets, setOffsets, setOffsets, setToolTip, setVerticalAlignment, setWidth, show, stopAcceptDrops, toggleStyleClass, toggleStyleClass, tr
Methods inherited from class eu.webtoolkit.jwt.WObject
getObjectName, setFormData
-
Constructor Details
-
WLabel
Creates a label with empty text and optional parent. -
WLabel
public WLabel()Creates a label with empty text and optional parent. -
WLabel
Creates a label with a given text. -
WLabel
Creates a label with a given text. -
WLabel
Creates a label with an image. -
WLabel
Creates a label with an image.
-
-
Method Details
-
remove
public void remove()Description copied from class:WWidget
Destructor.Deletes a widget and all contained contents.
- Overrides:
remove
in classWInteractWidget
- See Also:
-
getBuddy
Returns the buddy of this label.- See Also:
-
setBuddy
Sets the buddy of this label.Sets the buddy FormWidget for which this label acts as a proxy.
- See Also:
-
setText
Sets the label text. -
getText
Returns the label text. -
setTextFormat
Sets the text format.The textFormat controls how the string should be interpreted: either as plain text, which is displayed literally, or as XHTML-markup.
When changing the textFormat to
TextFormat.XHTML
, and the current text is literal (not created usingWString#tr()
), the current text is parsed using an XML parser which discards malicious tags and attributes silently. When the parser encounters an XML parse error, the textFormat is left unchanged, and this method returns false.Returns whether the textFormat could be set for the current text.
The default format is
TextFormat.XHTML
. -
getTextFormat
Returns the text format.- See Also:
-
setImage
Sets the image. -
setImage
Sets the image. -
getImage
Returns the image. -
setWordWrap
public void setWordWrap(boolean wordWrap) Configures word wrapping.When
wordWrap
istrue
, the widget may break lines, creating a multi-line text. WhenwordWrap
isfalse
, the text will displayed on a single line, unless the text contains end-of-lines (forTextFormat.Plain
) or <br /> tags or other block-level tags (forTextFormat.XHTML
).The default value is
false
.- See Also:
-
hasWordWrap
public boolean hasWordWrap()Returns whether word wrapping is on.- See Also:
-
getDomChanges
Description copied from class:WWebWidget
Get DOM changes for this widget.This is an internal function, and should not be called directly, or be overridden!
- Overrides:
getDomChanges
in classWWebWidget
-
propagateSetEnabled
protected void propagateSetEnabled(boolean enabled) Description copied from class:WWidget
Propagates that a widget was enabled or disabled through children.When enabling or disabling a widget, you usually also want to disable contained children. This method is called by
setDisabled()
to propagate its state to all children.You may want to reimplement this method if they wish to render differently when a widget is disabled. The default implementation will propagate the signal to all children.
- Overrides:
propagateSetEnabled
in classWInteractWidget
-
iterateChildren
- Overrides:
iterateChildren
in classWWebWidget
-
updateImage
-
updateText
-