Class WLabel
- java.lang.Object
-
- eu.webtoolkit.jwt.WObject
-
- eu.webtoolkit.jwt.WWidget
-
- eu.webtoolkit.jwt.WWebWidget
-
- eu.webtoolkit.jwt.WInteractWidget
-
- eu.webtoolkit.jwt.WLabel
-
public class WLabel extends WInteractWidget
A label for a form field.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
inlinewidget.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_, noDefault
-
Fields inherited from class eu.webtoolkit.jwt.WWidget
WT_GETEXTRAMS_JS
-
-
Constructor Summary
Constructors Constructor Description WLabel()Creates a label with empty text and optional parent.WLabel(WContainerWidget parentContainer)Creates a label with empty text and optional parent.WLabel(WImage image)Creates a label with an image.WLabel(WImage image, WContainerWidget parentContainer)Creates a label with an image.WLabel(java.lang.CharSequence text)Creates a label with a given text.WLabel(java.lang.CharSequence text, WContainerWidget parentContainer)Creates a label with a given text.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description WFormWidgetgetBuddy()Returns the buddy of this label.protected voidgetDomChanges(java.util.List<DomElement> result, WApplication app)Get DOM changes for this widget.WImagegetImage()Returns the image.WStringgetText()Returns the label text.TextFormatgetTextFormat()Returns the text format.booleanhasWordWrap()Returns whether word wrapping is on.protected voiditerateChildren(HandleWidgetMethod method)protected voidpropagateSetEnabled(boolean enabled)Propagates that a widget was enabled or disabled through children.voidremove()Destructor.voidsetBuddy(WFormWidget buddy)Sets the buddy of this label.voidsetImage(WImage image)Sets the image.voidsetImage(WImage image, Side side)Sets the image.voidsetText(java.lang.CharSequence text)Sets the label text.booleansetTextFormat(TextFormat format)Sets the text format.voidsetWordWrap(boolean wordWrap)Configures word wrapping.protected voidupdateImage(DomElement element, boolean all, WApplication app, int pos)protected voidupdateText(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, render, 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, hideToolTip, isCanReceiveFocus, isDisabled, isHidden, isHiddenKeepsGeometry, isInline, isLoaded, isPopup, isRendered, isScrollVisibilityEnabled, isScrollVisible, isSetFirstFocus, isThemeStyleEnabled, isVisible, jsStringLiteral, jsStringLiteral, manageWidget, parentResized, parentResized, propagateSetVisible, refresh, removeScript, removeStyleClass, 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, showToolTip, showToolTipOnHover, unescapeText, updateSignalConnection, voidEventSignal, widgetAdded, widgetRemoved
-
Methods inherited from class eu.webtoolkit.jwt.WWidget
acceptDrops, acceptDrops, addCssRule, addCssRule, addJSignal, addStyleClass, animateHide, animateShow, applyThemeStyles, boxBorder, boxPadding, createJavaScript, disable, dropEvent, enable, getDropTouch, getJsRef, getParent, hide, htmlText, isExposed, isGlobalWidget, isLayoutSizeAware, layoutSizeChanged, needsRerender, positionAt, positionAt, positionAt, positionAt, removeFromParent, removeStyleClass, removeWidget, render, resize, scheduleRender, scheduleRender, scheduleRender, scheduleThemeStyleApply, 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 Detail
-
WLabel
public WLabel(WContainerWidget parentContainer)
Creates a label with empty text and optional parent.
-
WLabel
public WLabel()
Creates a label with empty text and optional parent.
-
WLabel
public WLabel(java.lang.CharSequence text, WContainerWidget parentContainer)Creates a label with a given text.
-
WLabel
public WLabel(java.lang.CharSequence text)
Creates a label with a given text.
-
WLabel
public WLabel(WImage image, WContainerWidget parentContainer)
Creates a label with an image.
-
WLabel
public WLabel(WImage image)
Creates a label with an image.
-
-
Method Detail
-
remove
public void remove()
Description copied from class:WWidgetDestructor.Deletes a widget and all contained contents.
- Overrides:
removein classWInteractWidget- See Also:
WWidget.removeWidget(WWidget widget)
-
getBuddy
public WFormWidget getBuddy()
Returns the buddy of this label.- See Also:
setBuddy(WFormWidget buddy)
-
setBuddy
public void setBuddy(WFormWidget buddy)
Sets the buddy of this label.Sets the buddy FormWidget for which this label acts as a proxy.
- See Also:
WFormWidget.getLabel(),getBuddy()
-
setText
public void setText(java.lang.CharSequence text)
Sets the label text.
-
getText
public WString getText()
Returns the label text.
-
setTextFormat
public boolean setTextFormat(TextFormat format)
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
public TextFormat getTextFormat()
Returns the text format.- See Also:
setTextFormat(TextFormat format)
-
setImage
public final void setImage(WImage image)
Sets the image.
-
getImage
public WImage getImage()
Returns the image.
-
setWordWrap
public void setWordWrap(boolean wordWrap)
Configures word wrapping.When
wordWrapistrue, the widget may break lines, creating a multi-line text. WhenwordWrapisfalse, 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()
-
hasWordWrap
public boolean hasWordWrap()
Returns whether word wrapping is on.- See Also:
setWordWrap(boolean wordWrap)
-
getDomChanges
protected void getDomChanges(java.util.List<DomElement> result, WApplication app)
Description copied from class:WWebWidgetGet DOM changes for this widget.This is an internal function, and should not be called directly, or be overridden!
- Overrides:
getDomChangesin classWWebWidget
-
propagateSetEnabled
protected void propagateSetEnabled(boolean enabled)
Description copied from class:WWidgetPropagates 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:
propagateSetEnabledin classWInteractWidget
-
iterateChildren
protected void iterateChildren(HandleWidgetMethod method)
- Overrides:
iterateChildrenin classWWebWidget
-
updateImage
protected void updateImage(DomElement element, boolean all, WApplication app, int pos)
-
updateText
protected void updateText(DomElement element, boolean all, WApplication app, int pos)
-
-