Class TextBox

  • All Implemented Interfaces:
    com.google.gwt.event.dom.client.HasAllDragAndDropHandlers, com.google.gwt.event.dom.client.HasAllFocusHandlers, com.google.gwt.event.dom.client.HasAllGestureHandlers, com.google.gwt.event.dom.client.HasAllKeyHandlers, com.google.gwt.event.dom.client.HasAllMouseHandlers, com.google.gwt.event.dom.client.HasAllTouchHandlers, com.google.gwt.event.dom.client.HasBlurHandlers, com.google.gwt.event.dom.client.HasChangeHandlers, com.google.gwt.event.dom.client.HasClickHandlers, com.google.gwt.event.dom.client.HasDoubleClickHandlers, com.google.gwt.event.dom.client.HasDragEndHandlers, com.google.gwt.event.dom.client.HasDragEnterHandlers, com.google.gwt.event.dom.client.HasDragHandlers, com.google.gwt.event.dom.client.HasDragLeaveHandlers, com.google.gwt.event.dom.client.HasDragOverHandlers, com.google.gwt.event.dom.client.HasDragStartHandlers, com.google.gwt.event.dom.client.HasDropHandlers, com.google.gwt.event.dom.client.HasFocusHandlers, com.google.gwt.event.dom.client.HasGestureChangeHandlers, com.google.gwt.event.dom.client.HasGestureEndHandlers, com.google.gwt.event.dom.client.HasGestureStartHandlers, com.google.gwt.event.dom.client.HasKeyDownHandlers, com.google.gwt.event.dom.client.HasKeyPressHandlers, com.google.gwt.event.dom.client.HasKeyUpHandlers, com.google.gwt.event.dom.client.HasMouseDownHandlers, com.google.gwt.event.dom.client.HasMouseMoveHandlers, com.google.gwt.event.dom.client.HasMouseOutHandlers, com.google.gwt.event.dom.client.HasMouseOverHandlers, com.google.gwt.event.dom.client.HasMouseUpHandlers, com.google.gwt.event.dom.client.HasMouseWheelHandlers, com.google.gwt.event.dom.client.HasTouchCancelHandlers, com.google.gwt.event.dom.client.HasTouchEndHandlers, com.google.gwt.event.dom.client.HasTouchMoveHandlers, com.google.gwt.event.dom.client.HasTouchStartHandlers, com.google.gwt.event.logical.shared.HasAttachHandlers, com.google.gwt.event.logical.shared.HasValueChangeHandlers<String>, com.google.gwt.event.shared.HasHandlers, com.google.gwt.i18n.client.AutoDirectionHandler.Target, com.google.gwt.i18n.client.HasDirection, com.google.gwt.i18n.shared.HasDirectionEstimator, com.google.gwt.user.client.EventListener, com.google.gwt.user.client.TakesValue<String>, com.google.gwt.user.client.ui.Focusable, com.google.gwt.user.client.ui.HasEnabled, com.google.gwt.user.client.ui.HasFocus, com.google.gwt.user.client.ui.HasName, com.google.gwt.user.client.ui.HasText, com.google.gwt.user.client.ui.HasValue<String>, com.google.gwt.user.client.ui.HasVisibility, com.google.gwt.user.client.ui.IsWidget, com.google.gwt.user.client.ui.SourcesClickEvents, com.google.gwt.user.client.ui.SourcesFocusEvents, com.google.gwt.user.client.ui.SourcesKeyboardEvents, com.google.gwt.user.client.ui.SourcesMouseEvents, HasAutocomplete, HasAutofocus, HasDataList, HasFormNoValidate, HasPlaceholder, HasRequired, HasValidationMessageElement<String,​ValueBoxEditor<String>>, HasValidationPattern, HasValidity, org.gwtproject.editor.client.Editor<String>, org.gwtproject.editor.client.HasEditorErrors<String>, org.gwtproject.editor.client.IsEditor<ValueBoxEditor<String>>, org.gwtproject.editor.client.TakesValue<String>
    Direct Known Subclasses:
    AbstractFormatingTextBox, PostalCodeTextBox, RegExCheckedTextBox, TaxNumberTextBox, TextBoxWithFormating, TinTextBox, VatIdTextBox

    public class TextBox
    extends TextBoxBase
    A standard single-line text box.

    <img class='gallery' src='doc-files/TextBox.png'/>

    CSS Style Rules

    • .gwt-TextBox { primary style }
    • .gwt-TextBox-readonly { dependent style set when the text box is read-only }

    Built-in Bidi Text Support

    This widget is capable of automatically adjusting its direction according to the input text. This feature is controlled by ValueBoxBase.setDirectionEstimator(boolean), and is available by default when at least one of the application's locales is right-to-left.

    • Constructor Detail

      • TextBox

        public TextBox()
        Creates an empty text box.
      • TextBox

        protected TextBox​(com.google.gwt.dom.client.Element element)
        This constructor may be used by subclasses to explicitly use an existing element. This element must be an <input> element whose type is 'text'.
        Parameters:
        element - the element to be used
      • TextBox

        protected TextBox​(com.google.gwt.dom.client.Element element,
                          String styleName)
      • TextBox

        public TextBox​(com.google.gwt.dom.client.Element elem,
                       com.google.gwt.text.shared.Renderer<String> renderer,
                       com.google.gwt.text.shared.Parser<String> parser)
        Creates a text box that wraps the given browser element handle. This is only used by subclasses.
        Parameters:
        elem - the browser element to wrap
        renderer - renderer for rendering value
        parser - parser for parsing value
      • TextBox

        public TextBox​(elemental2.dom.HTMLInputElement element,
                       com.google.gwt.text.shared.Renderer<String> renderer,
                       com.google.gwt.text.shared.Parser<String> parser)
        Creates a text box that wraps the given browser element handle. This is only used by subclasses.
        Parameters:
        element - the browser element to wrap
        renderer - renderer for rendering value
        parser - parser for parsing value
    • Method Detail

      • wrap

        public static TextBox wrap​(com.google.gwt.dom.client.Element element)
        Creates a TextBox widget that wraps an existing <input type='text'> 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
        Returns:
        text box
      • getRenderer

        protected com.google.gwt.text.shared.Renderer<String> getRenderer()
      • getParser

        protected com.google.gwt.text.shared.Parser<String> getParser()
      • getMaxLength

        public int getMaxLength()
        Gets the maximum allowable length of the text box.
        Returns:
        the maximum length, in characters
      • getVisibleLength

        public int getVisibleLength()
        Gets the number of visible characters in the text box.
        Returns:
        the number of visible characters
      • setMaxLength

        public void setMaxLength​(int length)
        Sets the maximum allowable length of the text box.
        Parameters:
        length - the maximum length, in characters
      • setVisibleLength

        public void setVisibleLength​(int length)
        Sets the number of visible characters in the text box.
        Parameters:
        length - the number of visible characters