eu.webtoolkit.jwt
Class WLabel

java.lang.Object
  extended by eu.webtoolkit.jwt.WObject
      extended by eu.webtoolkit.jwt.WWidget
          extended by eu.webtoolkit.jwt.WWebWidget
              extended by eu.webtoolkit.jwt.WInteractWidget
                  extended by 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:

 {
        @code
        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.


Constructor Summary
WLabel()
          Creates a label with empty text and optional parent.
WLabel(java.lang.CharSequence text)
          Creates a label with a given text.
WLabel(java.lang.CharSequence text, WContainerWidget parent)
          Creates a label with a given text.
WLabel(WContainerWidget parent)
          Creates a label with empty text and optional parent.
WLabel(WImage image)
          Creates a label with an image.
WLabel(WImage image, WContainerWidget parent)
          Creates a label with an image.
 
Method Summary
 WFormWidget getBuddy()
          Returns the buddy of this label.
 WImage getImage()
          Returns the image.
 WString getText()
          Returns the label text.
 boolean hasWordWrap()
          Returns whether word wrapping is on.
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.
 void setImage(WImage image)
          Sets the image.
 void setImage(WImage image, Side side)
          Sets the image.
 void setText(java.lang.CharSequence text)
          Sets the label text.
 void setWordWrap(boolean wordWrap)
          Configures word wrapping.
protected  void updateImage(eu.webtoolkit.jwt.DomElement element, boolean all, WApplication app, int pos)
           
protected  void updateText(eu.webtoolkit.jwt.DomElement element, boolean all, WApplication app, int pos)
           
 
Methods inherited from class eu.webtoolkit.jwt.WInteractWidget
clicked, doubleClicked, enterPressed, escapePressed, gestureChanged, gestureEnded, gestureStarted, isEnabled, keyPressed, keyWentDown, keyWentUp, load, mouseDragged, mouseMoved, mouseWentDown, mouseWentOut, mouseWentOver, mouseWentUp, mouseWheel, setDraggable, setDraggable, setDraggable, setDraggable, touchEnded, touchMoved, touchStarted
 
Methods inherited from class eu.webtoolkit.jwt.WWebWidget
addStyleClass, callJavaScriptMember, childrenChanged, doJavaScript, domCanBeSaved, enableAjax, escapeText, escapeText, escapeText, escapeText, find, getAttributeValue, getChildren, getClearSides, getDecorationStyle, getFloatSide, getHeight, getId, getJavaScriptMember, getLineHeight, getMargin, getMaximumHeight, getMaximumWidth, getMinimumHeight, getMinimumWidth, getOffset, getPositionScheme, getStyleClass, getTabIndex, getToolTip, getVerticalAlignment, getVerticalAlignmentLength, getWidth, isDisabled, isHidden, isHiddenKeepsGeometry, isInline, isLoaded, isPopup, isRendered, isVisible, jsStringLiteral, jsStringLiteral, refresh, removeScript, removeStyleClass, render, resize, setAttributeValue, setClearSides, setDecorationStyle, setDisabled, setFloatSide, setHidden, setHiddenKeepsGeometry, setId, setInline, setJavaScriptMember, setLineHeight, setLoadLaterWhenInvisible, setMargin, setMaximumSize, setMinimumSize, setOffsets, setPopup, setPositionScheme, setSelectable, setStyleClass, setTabIndex, setToolTip, setVerticalAlignment, updateSignalConnection
 
Methods inherited from class eu.webtoolkit.jwt.WWidget
acceptDrops, acceptDrops, addCssRule, addCssRule, addStyleClass, animateHide, animateShow, boxBorder, boxPadding, containsExposed, disable, dropEvent, enable, getDrop, getJsRef, getParent, hide, htmlText, isLayoutSizeAware, layoutSizeChanged, positionAt, positionAt, removeStyleClass, resize, setClearSides, 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
addChild, getObjectName, setObjectName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WLabel

public WLabel(WContainerWidget parent)
Creates a label with empty text and optional parent.


WLabel

public WLabel()
Creates a label with empty text and optional parent.

Calls this((WContainerWidget)null)


WLabel

public WLabel(java.lang.CharSequence text,
              WContainerWidget parent)
Creates a label with a given text.


WLabel

public WLabel(java.lang.CharSequence text)
Creates a label with a given text.

Calls this(text, (WContainerWidget)null)


WLabel

public WLabel(WImage image,
              WContainerWidget parent)
Creates a label with an image.


WLabel

public WLabel(WImage image)
Creates a label with an image.

Calls this(image, (WContainerWidget)null)

Method Detail

remove

public void remove()
Description copied from class: WWidget
Destructor.

Deletes a widget and all children (recursively). If the widget is contained in another widget, it is removed first.

Overrides:
remove in class WInteractWidget
See Also:
WContainerWidget.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.


setImage

public void setImage(WImage image,
                     Side side)
Sets the image.


setImage

public final void setImage(WImage image)
Sets the image.

Calls setImage(image, Side.Left)


getImage

public WImage getImage()
Returns the image.


setWordWrap

public void setWordWrap(boolean wordWrap)
Configures word wrapping.

When wordWrap is true, the widget may break lines, creating a multi-line text. When wordWrap is false, the text will displayed on a single line, unless the text contains end-of-lines (for TextFormat.PlainText) or <br /> tags or other block-level tags (for TextFormat.XHTMLText).

The default value is false.

See Also:
hasWordWrap()

hasWordWrap

public boolean hasWordWrap()
Returns whether word wrapping is on.

See Also:
setWordWrap(boolean wordWrap)

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 class WInteractWidget

updateImage

protected void updateImage(eu.webtoolkit.jwt.DomElement element,
                           boolean all,
                           WApplication app,
                           int pos)

updateText

protected void updateText(eu.webtoolkit.jwt.DomElement element,
                          boolean all,
                          WApplication app,
                          int pos)