Class Anchor

All Implemented Interfaces:
HasAllDragAndDropHandlers, HasAllFocusHandlers, HasAllGestureHandlers, HasAllKeyHandlers, HasAllMouseHandlers, HasAllTouchHandlers, HasBlurHandlers, HasClickHandlers, HasDoubleClickHandlers, HasDragEndHandlers, HasDragEnterHandlers, HasDragHandlers, HasDragLeaveHandlers, HasDragOverHandlers, HasDragStartHandlers, HasDropHandlers, HasFocusHandlers, HasGestureChangeHandlers, HasGestureEndHandlers, HasGestureStartHandlers, HasKeyDownHandlers, HasKeyPressHandlers, HasKeyUpHandlers, HasMouseDownHandlers, HasMouseMoveHandlers, HasMouseOutHandlers, HasMouseOverHandlers, HasMouseUpHandlers, HasMouseWheelHandlers, HasTouchCancelHandlers, HasTouchEndHandlers, HasTouchMoveHandlers, HasTouchStartHandlers, HasAttachHandlers, HasHandlers, HasDirection, HasDirectionEstimator, HasSafeHtml, EventListener, Focusable, HasDirectionalSafeHtml, HasDirectionalText, HasEnabled, HasFocus, HasHorizontalAlignment, HasHTML, HasName, HasText, HasVisibility, HasWordWrap, IsWidget, SourcesClickEvents, SourcesFocusEvents, SourcesKeyboardEvents, SourcesMouseEvents

A widget that represents a simple <a> element.

If you want use this anchor only for changing history states, use Hyperlink instead.

Built-in Bidi Text Support

This widget is capable of automatically adjusting its direction according to its content. This feature is controlled by setDirectionEstimator(boolean) or passing a DirectionEstimator parameter to the constructor, and is off by default.

CSS Style Rules

  • .gwt-Anchor { }
See Also:
  • Field Details

    • DEFAULT_DIRECTION_ESTIMATOR

      public static final DirectionEstimator DEFAULT_DIRECTION_ESTIMATOR
  • Constructor Details

    • Anchor

      public Anchor()
      Creates an empty anchor.

      The anchor's href is not set, which means that the widget will not not be styled with the browser's native link styles (such as underline and font color). Use Anchor(boolean) to add a default no-op href that does not open a link but ensures the native link styles are applied.

      See Also:
    • Anchor

      public Anchor(boolean useDefaultHref)
      Creates an anchor. The anchor's href is optionally set to javascript:;, based on the expectation that listeners will be added to the anchor.
      Parameters:
      useDefaultHref - true to set the default href to javascript:;, false to leave it blank
    • Anchor

      public Anchor(SafeHtml html)
      Creates an anchor for scripting.
      Parameters:
      html - the anchor's html
    • Anchor

      public Anchor(SafeHtml html, HasDirection.Direction dir)
      Creates an anchor for scripting. The anchor's href is set to javascript : ;, based on the expectation that listeners will be added to the anchor.
      Parameters:
      html - the anchor's html
      dir - the html's direction
    • Anchor

      public Anchor(SafeHtml html, DirectionEstimator directionEstimator)
      Creates an anchor for scripting. The anchor's href is set to javascript : ;, based on the expectation that listeners will be added to the anchor.
      Parameters:
      html - the anchor's html
      directionEstimator - A DirectionEstimator object used for automatic direction adjustment. For convenience, DEFAULT_DIRECTION_ESTIMATOR can be used.
    • Anchor

      public Anchor(String text)
      Creates an anchor for scripting. The anchor's href is set to javascript:;, based on the expectation that listeners will be added to the anchor.
      Parameters:
      text - the anchor's text
    • Anchor

      public Anchor(String text, HasDirection.Direction dir)
      Creates an anchor for scripting. The anchor's href is set to javascript : ;, based on the expectation that listeners will be added to the anchor.
      Parameters:
      text - the anchor's text
      dir - the text's direction
    • Anchor

      public Anchor(String text, DirectionEstimator directionEstimator)
      Creates an anchor for scripting. The anchor's href is set to javascript : ;, based on the expectation that listeners will be added to the anchor.
      Parameters:
      text - the anchor's text
      directionEstimator - A DirectionEstimator object used for automatic direction adjustment. For convenience, DEFAULT_DIRECTION_ESTIMATOR can be used.
    • Anchor

      public Anchor(String text, boolean asHtml)
      Creates an anchor for scripting. The anchor's href is set to javascript:;, based on the expectation that listeners will be added to the anchor.
      Parameters:
      text - the anchor's text
      asHtml - true to treat the specified text as html
    • Anchor

      public Anchor(SafeHtml html, String href)
      Creates an anchor with its html and href (target URL) specified.
      Parameters:
      html - the anchor's html
      href - the url to which it will link
    • Anchor

      public Anchor(SafeHtml html, SafeUri href)
      Creates an anchor with its html and href (target URL) specified.
      Parameters:
      html - the anchor's html
      href - the url to which it will link
    • Anchor

      public Anchor(SafeHtml html, HasDirection.Direction dir, String href)
      Creates an anchor with its html and href (target URL) specified.
      Parameters:
      html - the anchor's html
      dir - the html's direction
      href - the url to which it will link
    • Anchor

      public Anchor(SafeHtml html, HasDirection.Direction dir, SafeUri href)
      Creates an anchor with its html and href (target URL) specified.
      Parameters:
      html - the anchor's html
      dir - the html's direction
      href - the url to which it will link
    • Anchor

      public Anchor(SafeHtml html, DirectionEstimator directionEstimator, String href)
      Creates an anchor with its html and href (target URL) specified.
      Parameters:
      html - the anchor's html
      directionEstimator - A DirectionEstimator object used for automatic direction adjustment. For convenience, DEFAULT_DIRECTION_ESTIMATOR can be used.
      href - the url to which it will link
    • Anchor

      public Anchor(SafeHtml html, DirectionEstimator directionEstimator, SafeUri href)
      Creates an anchor with its html and href (target URL) specified.
      Parameters:
      html - the anchor's html
      directionEstimator - A DirectionEstimator object used for automatic direction adjustment. For convenience, DEFAULT_DIRECTION_ESTIMATOR can be used.
      href - the url to which it will link
    • Anchor

      public Anchor(String text, String href)
      Creates an anchor with its text and href (target URL) specified.
      Parameters:
      text - the anchor's text
      href - the url to which it will link
    • Anchor

      public Anchor(String text, HasDirection.Direction dir, String href)
      Creates an anchor with its text and href (target URL) specified.
      Parameters:
      text - the anchor's text
      dir - the text's direction
      href - the url to which it will link
    • Anchor

      public Anchor(String text, DirectionEstimator directionEstimator, String href)
      Creates an anchor with its text and href (target URL) specified.
      Parameters:
      text - the anchor's text
      directionEstimator - A DirectionEstimator object used for automatic direction adjustment. For convenience, DEFAULT_DIRECTION_ESTIMATOR can be used.
      href - the url to which it will link
    • Anchor

      public Anchor(String text, boolean asHTML, String href)
      Creates an anchor with its text and href (target URL) specified.
      Parameters:
      text - the anchor's text
      asHTML - true to treat the specified text as html
      href - the url to which it will link
    • Anchor

      public Anchor(SafeHtml html, String href, String target)
      Creates a source anchor (link to URI). That is, an anchor with an href attribute specifying the destination URI.
      Parameters:
      html - the anchor's html
      href - the url to which it will link
      target - the target frame (e.g. "_blank" to open the link in a new window)
    • Anchor

      public Anchor(SafeHtml html, SafeUri href, String target)
      Creates a source anchor (link to URI). That is, an anchor with an href attribute specifying the destination URI.
      Parameters:
      html - the anchor's html
      href - the url to which it will link
      target - the target frame (e.g. "_blank" to open the link in a new window)
    • Anchor

      public Anchor(String text, String href, String target)
      Creates a source anchor with a frame target.
      Parameters:
      text - the anchor's text
      href - the url to which it will link
      target - the target frame (e.g. "_blank" to open the link in a new window)
    • Anchor

      public Anchor(String text, boolean asHtml, String href, String target)
      Creates a source anchor (link to URI). That is, an anchor with an href attribute specifying the destination URI.
      Parameters:
      text - the anchor's text
      asHtml - asHTML true to treat the specified text as html
      href - the url to which it will link
      target - the target frame (e.g. "_blank" to open the link in a new window)
    • Anchor

      protected Anchor(Element element)
      This constructor may be used by subclasses to explicitly use an existing element. This element must be an <a> element.
      Parameters:
      element - the element to be used
  • Method Details