Class HTML

    • Constructor Detail

      • HTML

        public HTML()
        Creates an empty HTML widget.
      • HTML

        public HTML​(SafeHtml html)
        Initializes the widget's HTML from a given SafeHtml object.
        Parameters:
        html - the new widget's HTML contents
      • HTML

        public HTML​(SafeHtml html,
                    HasDirection.Direction dir)
        Creates an HTML widget with the specified contents and with the specified direction.
        Parameters:
        html - the new widget's SafeHtml contents
        dir - the content's direction. Note: Direction.DEFAULT means direction should be inherited from the widget's parent element.
      • HTML

        public HTML​(SafeHtml html,
                    DirectionEstimator directionEstimator)
        Creates an HTML widget with the specified HTML contents and specifies a direction estimator.
        Parameters:
        html - the new widget's SafeHtml contents
        directionEstimator - A DirectionEstimator object used for automatic direction adjustment. For convenience, Label.DEFAULT_DIRECTION_ESTIMATOR can be used.
      • HTML

        public HTML​(java.lang.String html)
        Creates an HTML widget with the specified HTML contents.
        Parameters:
        html - the new widget's HTML contents
      • HTML

        public HTML​(java.lang.String html,
                    HasDirection.Direction dir)
        Creates an HTML widget with the specified HTML contents and with the specified direction.
        Parameters:
        html - the new widget's HTML contents
        dir - the content's direction. Note: Direction.DEFAULT means direction should be inherited from the widget's parent element.
      • HTML

        public HTML​(java.lang.String html,
                    boolean wordWrap)
        Creates an HTML widget with the specified contents, optionally treating it as HTML, and optionally disabling word wrapping.
        Parameters:
        html - the widget's contents
        wordWrap - false to disable word wrapping
      • HTML

        protected HTML​(Element element)
        This constructor may be used by subclasses to explicitly use an existing element. This element must be either a <div> or <span> element.
        Parameters:
        element - the element to be used
    • Method Detail

      • wrap

        public static HTML wrap​(Element element)
        Creates an HTML widget that wraps an existing <div> or <span> element. This element must already be attached to the document. If the element is removed from the document, you must call RootPanel.detachNow(Widget).
        Parameters:
        element - the element to be wrapped
      • getHTML

        public java.lang.String getHTML()
        Description copied from interface: HasHTML
        Gets this object's contents as HTML.
        Specified by:
        getHTML in interface HasHTML
        Returns:
        the object's HTML
      • setHTML

        public void setHTML​(java.lang.String html)
        Sets the label's content to the given HTML. See Label.setText(String) for details on potential effects on direction and alignment.
        Specified by:
        setHTML in interface HasHTML
        Parameters:
        html - the new widget's HTML content
      • setHTML

        public void setHTML​(java.lang.String html,
                            HasDirection.Direction dir)
        Sets the label's content to the given HTML, applying the given direction. See setText(String, Direction) for details on potential effects on alignment.
        Specified by:
        setHTML in interface HasDirectionalHtml
        Parameters:
        html - the new widget's HTML content
        dir - the content's direction. Note: Direction.DEFAULT means direction should be inherited from the widget's parent element.
      • getTextOrHtml

        protected java.lang.String getTextOrHtml​(boolean isHtml)