public class

LabelBase

extends Widget
implements HasDirectionEstimator HasAutoHorizontalAlignment HasWordWrap
java.lang.Object
   ↳ com.google.gwt.user.client.ui.UIObject
     ↳ com.google.gwt.user.client.ui.Widget
       ↳ com.google.gwt.user.client.ui.LabelBase<T>
Known Direct Subclasses
Known Indirect Subclasses

Class Overview

Abstract base class for all text display widgets.

Use in UiBinder Templates

Summary

[Expand]
Inherited Constants
From class com.google.gwt.user.client.ui.UIObject
[Expand]
Inherited Fields
From interface com.google.gwt.user.client.ui.HasAutoHorizontalAlignment
From interface com.google.gwt.user.client.ui.HasHorizontalAlignment
Protected Constructors
LabelBase(boolean inline)
LabelBase(Element element)
Public Methods
HasHorizontalAlignment.AutoHorizontalAlignmentConstant getAutoHorizontalAlignment()
Gets the horizontal auto-alignment setting.
DirectionEstimator getDirectionEstimator()
Returns the DirectionEstimator object.
HasHorizontalAlignment.HorizontalAlignmentConstant getHorizontalAlignment()
Gets the horizontal alignment.
boolean getWordWrap()
Gets whether word-wrapping is enabled.
void setAutoHorizontalAlignment(HasHorizontalAlignment.AutoHorizontalAlignmentConstant autoAlignment)
Sets the horizontal alignment, allowing in addition to the "static" HasHorizontalAlignment.HorizontalAlignmentConstant values, the "automatic" HasHorizontalAlignment.AutoHorizontalAlignmentConstant values that depend on the content direction.
void setDirectionEstimator(DirectionEstimator directionEstimator)
Sets the DirectionEstimator object.

Note: DirectionEstimator should be set before the widget has any content; it's highly recommended to set it using a constructor.

void setDirectionEstimator(boolean enabled)
Toggles on / off direction estimation.

See note at setDirectionEstimator(DirectionEstimator).

void setHorizontalAlignment(HasHorizontalAlignment.HorizontalAlignmentConstant align)
Sets the horizontal alignment.

Note: A subsequent call to setAutoHorizontalAlignment(HasHorizontalAlignment.AutoHorizontalAlignmentConstant) may override the horizontal alignment set by this method.

void setWordWrap(boolean wrap)
Sets whether word-wrapping is enabled.
Protected Methods
void updateHorizontalAlignment()
Sets the horizontal alignment of the widget according to the current AutoHorizontalAlignment setting.
[Expand]
Inherited Methods
From class com.google.gwt.user.client.ui.Widget
From class com.google.gwt.user.client.ui.UIObject
From class java.lang.Object
From interface com.google.gwt.event.logical.shared.HasAttachHandlers
From interface com.google.gwt.event.shared.HasHandlers
From interface com.google.gwt.i18n.shared.HasDirectionEstimator
From interface com.google.gwt.user.client.EventListener
From interface com.google.gwt.user.client.ui.HasAutoHorizontalAlignment
From interface com.google.gwt.user.client.ui.HasHorizontalAlignment
From interface com.google.gwt.user.client.ui.HasWordWrap
From interface com.google.gwt.user.client.ui.IsWidget

Protected Constructors

protected LabelBase (boolean inline)

protected LabelBase (Element element)

Public Methods

public HasHorizontalAlignment.AutoHorizontalAlignmentConstant getAutoHorizontalAlignment ()

Gets the horizontal auto-alignment setting. This may be one of the auto-alignment values above that depend on content direction (e.g. ALIGN_CONTENT_START), or one of the "static" HasHorizontalAlignment.HorizontalAlignmentConstant alignment values (e.g. ALIGN_LOCALE_START). It may be set by either setAutoHorizontalAlignment or HasHorizontalAlignment#setHorizontalAlignment. The default is null, indicating that no specific horizontal alignment has been set, allowing it to be determined by the usual HTML and CSS mechanisms.

Returns
  • the current automatic horizontal alignment policy.

public DirectionEstimator getDirectionEstimator ()

Returns the DirectionEstimator object.

public HasHorizontalAlignment.HorizontalAlignmentConstant getHorizontalAlignment ()

Gets the horizontal alignment.

Returns

public boolean getWordWrap ()

Gets whether word-wrapping is enabled.

Returns
  • true if word-wrapping is enabled.

public void setAutoHorizontalAlignment (HasHorizontalAlignment.AutoHorizontalAlignmentConstant autoAlignment)

Sets the horizontal alignment, allowing in addition to the "static" HasHorizontalAlignment.HorizontalAlignmentConstant values, the "automatic" HasHorizontalAlignment.AutoHorizontalAlignmentConstant values that depend on the content direction. Determines the values returned by both getAutoHorizontalAlignment() and getHorizontalAlignment().

For the ALIGN_CONTENT_START and ALIGN_CONTENT_END values, sets the horizontal alignment (including the value of HasHorizontalAlignment#getHorizontalAlignment()) to the start or end edge of the current content's direction, respectively, and continues to automatically update it whenever the content direction changes.

For other values, operates like setHorizontalAlignment(HasHorizontalAlignment.HorizontalAlignmentConstant).

For null, the horizontal alignment is cleared, allowing it to be determined by the standard HTML mechanisms such as inheritance and CSS rules.

Parameters
autoAlignment the new automatic horizontal alignment policy

public void setDirectionEstimator (DirectionEstimator directionEstimator)

Sets the DirectionEstimator object.

Note: DirectionEstimator should be set before the widget has any content; it's highly recommended to set it using a constructor. Reason: if the widget already has non-empty content, this will update its direction according to the new estimator's result. This may cause flicker, and thus should be avoided.

Parameters
directionEstimator The {code DirectionEstimator} to be set. null means turning off direction estimation.

public void setDirectionEstimator (boolean enabled)

Toggles on / off direction estimation.

See note at setDirectionEstimator(DirectionEstimator).

Parameters
enabled Whether to enable direction estimation. If true, sets the DirectionEstimator object to a default DirectionEstimator.

public void setHorizontalAlignment (HasHorizontalAlignment.HorizontalAlignmentConstant align)

Sets the horizontal alignment.

Use null to clear horizontal alignment, allowing it to be determined by the standard HTML mechanisms such as inheritance and CSS rules.

Note: A subsequent call to setAutoHorizontalAlignment(HasHorizontalAlignment.AutoHorizontalAlignmentConstant) may override the horizontal alignment set by this method.

Note: For null, the horizontal alignment is cleared, allowing it to be determined by the standard HTML mechanisms such as inheritance and CSS rules.

Parameters
align the horizontal alignment ( ALIGN_LEFT, ALIGN_CENTER, ALIGN_RIGHT, ALIGN_JUSTIFY, ALIGN_LOCALE_START, or ALIGN_LOCALE_END).

public void setWordWrap (boolean wrap)

Sets whether word-wrapping is enabled.

Parameters
wrap true to enable word-wrapping.

Protected Methods

protected void updateHorizontalAlignment ()

Sets the horizontal alignment of the widget according to the current AutoHorizontalAlignment setting. Should be invoked whenever the horizontal alignment may be affected, i.e. on every modification of the content or its direction.