Class AutoCompleteTextComponent

All Implemented Interfaces:
Animation, Editable, StyleListener, Iterable<Component>

public class AutoCompleteTextComponent extends TextComponent

A TextComponent version of com.codename1.ui.AutoCompleteTextField

This component was contributed here https://github.com/codenameone/CodenameOne/issues/2705

  • Constructor Details

  • Method Details

    • getField

      public TextField getField()

      Allows us to invoke setters/getters and bind listeners to the text field

      Returns

      the text field instance

      Overrides:
      getField in class TextComponent
    • getEditor

      public final Component getEditor()

      Returns the editor component e.g. text field picker etc.

      Returns

      the editor component

      Overrides:
      getEditor in class TextComponent
    • isFocusAnimation

      public boolean isFocusAnimation()

      The focus animation mode forces the hint and text to be identical and animates the hint to the label when focus is in the text field as is common on Android. This can be customized using the theme constant textComponentAnimBool which is true by default on Android. Notice that this is designed for the onTopMode and might not work if that is set to false...

      Returns

      true if the text should be on top

      Overrides:
      isFocusAnimation in class TextComponent
    • focusAnimation

      public AutoCompleteTextComponent focusAnimation(boolean focusAnimation)

      The focus animation mode forces the hint and text to be identical and animates the hint to the label when focus is in the text field as is common on Android. This can be customized using the theme constant textComponentAnimBool which is true by default on Android. Notice that this is designed for the onTopMode and might not work if that is set to false...

      Parameters
      • focusAnimation: @param focusAnimation true for the label to animate into place on focus, false otherwise
      Returns

      this for chaining calls E.g. AutoCompleteTextComponent tc = new AutoCompleteTextComponent().text("Text").label("Label");

      Overrides:
      focusAnimation in class TextComponent
    • text

      public AutoCompleteTextComponent text(String text)

      Sets the text of the field

      Parameters
      • text: the text
      Returns

      this for chaining calls E.g. AutoCompleteTextComponent tc = new AutoCompleteTextComponent().text("Text").label("Label");

      Overrides:
      text in class TextComponent
    • onTopMode

      public AutoCompleteTextComponent onTopMode(boolean onTopMode)

      Overridden for covariant return type

      Overridden for covariant return type

      Sets the on top mode which places the label above the text when true. It's to the left of the text otherwise (right in bidi languages). This is determined by the platform theme using the textComponentOnTopBool theme constant which defaults to false

      Parameters
      • onTopMode: true for the label to be above the text
      Returns

      this for chaining calls E.g. TextComponent tc = new TextComponent().text("Text").label("Label");

      Overrides:
      onTopMode in class TextComponent
    • descriptionMessage

      public AutoCompleteTextComponent descriptionMessage(String descriptionMessage)

      Overridden for covariant return type

      Overridden for covariant return type

      Sets the text of the description label which currently only applies in the onTop mode. This text occupies the same space as the error message and thus hides when there's an error

      Parameters
      • descriptionMessage: the text
      Returns

      this for chaining calls E.g. TextComponent tc = new TextComponent().text("Text").label("Label");

      Overrides:
      descriptionMessage in class TextComponent
    • errorMessage

      public AutoCompleteTextComponent errorMessage(String errorMessage)

      Overridden for covariant return type

      Overridden for covariant return type

      Sets the text of the error label

      Parameters
      • errorMessage: the text
      Returns

      this for chaining calls E.g. TextComponent tc = new TextComponent().text("Text").label("Label");

      Overrides:
      errorMessage in class TextComponent
    • label

      public AutoCompleteTextComponent label(String text)

      Overridden for covariant return type *

      Overridden for covariant return type

      Sets the text of the label

      Parameters
      • text: the text
      Returns

      this for chaining calls E.g. TextComponent tc = new TextComponent().text("Text").label("Label");

      }

      Overrides:
      label in class TextComponent
    • labelAndHint

      public AutoCompleteTextComponent labelAndHint(String text)

      Convenience method for setting the label and hint together

      Parameters
      • text: the text and hint
      Returns

      this for chaining calls E.g. AutoCompleteTextComponent tc = new AutoCompleteTextComponent().text("Text").label("Label");

      Overrides:
      labelAndHint in class TextComponent
    • hint

      public AutoCompleteTextComponent hint(String hint)

      Sets the hint of the field

      Parameters
      • hint: the text of the hint
      Returns

      this for chaining calls E.g. AutoCompleteTextComponent tc = new AutoCompleteTextComponent().text("Text").label("Label");

      Overrides:
      hint in class TextComponent
    • hint

      public AutoCompleteTextComponent hint(Image hint)

      Sets the hint of the field

      Parameters
      • hint: the icon for the hint
      Returns

      this for chaining calls E.g. AutoCompleteTextComponent tc = new AutoCompleteTextComponent().text("Text").label("Label");

      Overrides:
      hint in class TextComponent
    • multiline

      public AutoCompleteTextComponent multiline(boolean multiline)

      Sets the text field to multiline or single line

      Parameters
      • multiline: true for multiline, false otherwise
      Returns

      this for chaining calls E.g. AutoCompleteTextComponent tc = new AutoCompleteTextComponent().text("Text").label("Label");

      Overrides:
      multiline in class TextComponent
    • columns

      public AutoCompleteTextComponent columns(int columns)

      Sets the columns in the text field

      Parameters
      • columns: @param columns the number of columns which is used for preferred size calculations
      Returns

      this for chaining calls E.g. AutoCompleteTextComponent tc = new AutoCompleteTextComponent().text("Text").label("Label");

      Overrides:
      columns in class TextComponent
    • rows

      public AutoCompleteTextComponent rows(int rows)

      Sets the rows in the text field

      Parameters
      • rows: @param rows the number of rows which is used for preferred size calculations
      Returns

      this for chaining calls E.g. AutoCompleteTextComponent tc = new AutoCompleteTextComponent().text("Text").label("Label");

      Overrides:
      rows in class TextComponent
    • constraint

      public AutoCompleteTextComponent constraint(int constraint)

      Sets the constraint for text input matching the constraints from the text area class

      Parameters
      • constraint: @param constraint one of the constants from the com.codename1.ui.TextArea class see com.codename1.ui.TextArea#setConstraint(int)
      Returns

      this for chaining calls E.g. AutoCompleteTextComponent tc = new AutoCompleteTextComponent().text("Text").label("Label");

      Overrides:
      constraint in class TextComponent
    • getAutoCompleteField

      public AutoCompleteTextField getAutoCompleteField()

      Allows us to invoke setters/getters and bind listeners to the text field

      Returns

      the text field instance

    • getPropertyNames

      public String[] getPropertyNames()

      A component may expose mutable property names for a UI designer to manipulate, this API is designed for usage internally by the GUI builder code

      Returns

      the property names allowing mutation

      Overrides:
      getPropertyNames in class TextComponent
    • getPropertyTypes

      public Class[] getPropertyTypes()

      Matches the property names method (see that method for further details).

      Returns

      the types of the properties

      Overrides:
      getPropertyTypes in class TextComponent
    • getPropertyTypeNames

      public String[] getPropertyTypeNames()

      This method is here to workaround an XMLVM array type bug where property types aren't identified properly, it returns the names of the types using the following type names: String,int,double,long,byte,short,char,String[],String[][],byte[],Image,Image[],Object[],ListModel,ListCellRenderer

      Returns

      Array of type names

      Overrides:
      getPropertyTypeNames in class TextComponent
    • getPropertyValue

      public Object getPropertyValue(String name)

      Returns the current value of the property name, this method is used by the GUI builder

      Parameters
      • name: the name of the property
      Returns

      the value of said property

      Overrides:
      getPropertyValue in class TextComponent
    • setPropertyValue

      public String setPropertyValue(String name, Object value)

      Sets a new value to the given property, returns an error message if failed and null if successful. Notice that some builtin properties such as "$designMode" might be sent to components to indicate application state.

      Parameters
      • name: the name of the property

      • value: new value for the property

      Returns

      error message or null

      Overrides:
      setPropertyValue in class TextComponent
    • getText

      public String getText()

      Returns the text in the field com.codename1.ui.TextArea#getText()

      Returns

      the text

      Overrides:
      getText in class TextComponent