Class AutoCompleteTextComponent
- All Implemented Interfaces:
Animation, Editable, StyleListener, Iterable<Component>
A TextComponent version of com.codename1.ui.AutoCompleteTextField
This component was contributed here https://github.com/codenameone/CodenameOne/issues/2705
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceAllows filtering the entries in the auto complete -
Field Summary
Fields inherited from class Component
BASELINE, BOTTOM, BRB_CENTER_OFFSET, BRB_CONSTANT_ASCENT, BRB_CONSTANT_DESCENT, BRB_OTHER, CENTER, CROSSHAIR_CURSOR, DEFAULT_CURSOR, DRAG_REGION_IMMEDIATELY_DRAG_X, DRAG_REGION_IMMEDIATELY_DRAG_XY, DRAG_REGION_IMMEDIATELY_DRAG_Y, DRAG_REGION_LIKELY_DRAG_X, DRAG_REGION_LIKELY_DRAG_XY, DRAG_REGION_LIKELY_DRAG_Y, DRAG_REGION_NOT_DRAGGABLE, DRAG_REGION_POSSIBLE_DRAG_X, DRAG_REGION_POSSIBLE_DRAG_XY, DRAG_REGION_POSSIBLE_DRAG_Y, E_RESIZE_CURSOR, HAND_CURSOR, LEFT, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NW_RESIZE_CURSOR, RIGHT, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, TOP, W_RESIZE_CURSOR, WAIT_CURSOR -
Constructor Summary
ConstructorsConstructorDescriptionAutoCompleteTextComponent(ListModel<String> listModel, AutoCompleteTextComponent.AutoCompleteFilter customFilter) This constructor allows us to create an AutoCompleteTextComponent with the given listModel and customFilter -
Method Summary
Modifier and TypeMethodDescriptioncolumns(int columns) Sets the columns in the text fieldconstraint(int constraint) Sets the constraint for text input matching the constraints from the text area classdescriptionMessage(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.errorMessage(String errorMessage) Overridden for covariant return type Overridden for covariant return type Sets the text of the error labelfocusAnimation(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.Allows us to invoke setters/getters and bind listeners to the text fieldfinal ComponentReturns the editor component e.g.getField()Allows us to invoke setters/getters and bind listeners to the text fieldString[]A component may expose mutable property names for a UI designer to manipulate, this API is designed for usage internally by the GUI builder codeString[]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,ListCellRendererClass[]Matches the property names method (see that method for further details).getPropertyValue(String name) Returns the current value of the property name, this method is used by the GUI buildergetText()Returns the text in the fieldcom.codename1.ui.TextArea#getText()Sets the hint of the fieldSets the hint of the fieldbooleanThe 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.Overridden for covariant return type * Overridden for covariant return type Sets the text of the labellabelAndHint(String text) Convenience method for setting the label and hint togethermultiline(boolean multiline) Sets the text field to multiline or single lineonTopMode(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.rows(int rows) Sets the rows in the text fieldsetPropertyValue(String name, Object value) Sets a new value to the given property, returns an error message if failed and null if successful.Sets the text of the fieldMethods inherited from class TextComponent
action, actionAsButton, actionClick, actionText, actionUIIDMethods inherited from class InputComponent
calcPreferredSize, createErrorLabel, getAction, getActionText, getActionUIID, group, initInput, isActionAsButton, isMultiLineErrorMessage, isOnTopMode, setMultiLineErrorMessageMethods inherited from class Container
add, add, add, add, add, add, addAll, addComponent, addComponent, addComponent, addComponent, animateHierarchy, animateHierarchyAndWait, animateHierarchyFade, animateHierarchyFadeAndWait, animateLayout, animateLayoutAndWait, animateLayoutFade, animateLayoutFadeAndWait, animateUnlayout, animateUnlayoutAndWait, applyRTL, cancelRepaints, clearClientProperties, constrainHeightWhenScrollable, constrainWidthWhenScrollable, contains, createAnimateHierarchy, createAnimateHierarchyFade, createAnimateLayout, createAnimateLayoutFade, createAnimateLayoutFadeAndWait, createAnimateMotion, createAnimateUnlayout, createReplaceTransition, dragInitiated, drop, encloseIn, encloseIn, findDropTargetAt, findFirstFocusable, fireClicked, flushReplace, forceRevalidate, getBottomGap, getChildrenAsList, getClosestComponentTo, getComponentAt, getComponentAt, getComponentCount, getComponentIndex, getGridPosX, getGridPosY, getLayout, getLayoutHeight, getLayoutWidth, getLeadComponent, getLeadParent, getResponderAt, getSafeAreaRoot, getScrollIncrement, getSideGap, getUIManager, initLaf, invalidate, isEnabled, isSafeArea, isSafeAreaRoot, isScrollableX, isScrollableY, isSelectableInteraction, isSurface, iterator, iterator, keyPressed, keyReleased, layoutContainer, morph, morphAndWait, paint, paintComponentBackground, paintGlass, paramString, pointerPressed, refreshTheme, removeAll, removeComponent, replace, replace, replaceAndWait, replaceAndWait, replaceAndWait, revalidate, revalidateLater, revalidateWithAnimationSafety, scrollComponentToVisible, setCellRenderer, setEnabled, setLayout, setLeadComponent, setSafeArea, setSafeAreaRoot, setScrollable, setScrollableX, setScrollableY, setScrollIncrement, setShouldCalcPreferredSize, setShouldLayout, setUIManager, updateTabIndicesMethods inherited from class Component
addDragFinishedListener, addDragOverListener, addDropListener, addFocusListener, addLongPressListener, addPointerDraggedListener, addPointerPressedListener, addPointerReleasedListener, addPullToRefresh, addScrollListener, addStateChangeListener, animate, announceForAccessibility, bindProperty, blocksSideSwipe, calcScrollSize, contains, containsOrOwns, createStyleAnimation, deinitialize, deinitializeCustomStyle, dragEnter, dragExit, dragFinished, draggingOver, drawDraggedImage, focusGained, focusLost, getAbsoluteX, getAbsoluteY, getAccessibilityText, getAllStyles, getAnimationManager, getBaseline, getBaselineResizeBehavior, getBindablePropertyNames, getBindablePropertyTypes, getBorder, getBoundPropertyValue, getBounds, getBounds, getClientProperty, getCloudBoundProperty, getCloudDestinationProperty, getComponentForm, getComponentState, getCursor, getDefaultDragTransparency, getDirtyRegion, getDisabledStyle, getDraggedx, getDraggedy, getDragImage, getDragRegionStatus, getDragSpeed, getDragTransparency, getEditingDelegate, getHeight, getInlineAllStyles, getInlineDisabledStyles, getInlinePressedStyles, getInlineSelectedStyles, getInlineStylesTheme, getInlineUnselectedStyles, getInnerHeight, getInnerPreferredH, getInnerPreferredW, getInnerWidth, getInnerX, getInnerY, getLabelForComponent, getName, getNativeOverlay, getNextFocusDown, getNextFocusLeft, getNextFocusRight, getNextFocusUp, getOuterHeight, getOuterPreferredH, getOuterPreferredW, getOuterWidth, getOuterX, getOuterY, getOwner, getParent, getPreferredH, getPreferredSize, getPreferredSizeStr, getPreferredTabIndex, getPreferredW, getPressedStyle, getSameHeight, getSameWidth, getScrollable, getScrollAnimationSpeed, getScrollDimension, getScrollOpacity, getScrollOpacityChangeSpeed, getScrollX, getScrollY, getSelectCommandText, getSelectedRect, getSelectedStyle, getStyle, getTabIndex, getTensileLength, getTextSelectionSupport, getTooltip, getUIID, getUnselectedStyle, getVisibleBounds, getVisibleBounds, getWidth, getX, getY, growShrink, handlesInput, hasFixedPreferredSize, hasFocus, hideNativeOverlay, initComponent, initCustomStyle, initDisabledStyle, initPressedStyle, initSelectedStyle, initUnselectedStyle, installDefaultPainter, isAlwaysTensile, isBlockLead, isCellRenderer, isChildOf, isDragActivated, isDragAndDropOperation, isDraggable, isDragRegion, isDropTarget, isEditable, isEditing, isFlatten, isFocusable, isGrabsPointerEvents, isHidden, isHidden, isHideInLandscape, isHideInPortrait, isIgnorePointerEvents, isInClippingRegion, isInitialized, isOpaque, isOwnedBy, isPinchBlocksDragAndDrop, isRippleEffect, isRTL, isScrollable, isScrollVisible, isSetCursorSupported, isSmoothScrolling, isSnapToGrid, isStickyDrag, isTactileTouch, isTactileTouch, isTensileDragEnabled, isTraversable, isVisible, keyRepeated, laidOut, longKeyPress, longPointerPress, onScrollX, onScrollY, onSetFocusable, paintBackground, paintBackgrounds, paintBorder, paintBorderBackground, paintComponent, paintComponent, paintIntersectingComponentsAbove, paintLock, paintLockRelease, paintRippleOverlay, paintScrollbars, paintScrollbarX, paintScrollbarY, paintShadows, parsePreferredSize, pinch, pinch, pinchReleased, pointerDragged, pointerDragged, pointerHover, pointerHoverPressed, pointerHoverReleased, pointerPressed, pointerReleased, pointerReleased, putClientProperty, refreshTheme, refreshTheme, remove, removeDragFinishedListener, removeDragOverListener, removeDropListener, removeFocusListener, removeLongPressListener, removePointerDraggedListener, removePointerPressedListener, removePointerReleasedListener, removeScrollListener, removeStateChangeListener, repaint, repaint, requestFocus, resetFocusable, respondsToPointerEvents, scrollRectToVisible, scrollRectToVisible, setAccessibilityText, setAlwaysTensile, setBlockLead, setBoundPropertyValue, setCloudBoundProperty, setCloudDestinationProperty, setComponentState, setCursor, setDefaultDragTransparency, setDirtyRegion, setDisabledStyle, setDraggable, setDragTransparency, setDropTarget, setEditingDelegate, setFlatten, setFocus, setFocusable, setGrabsPointerEvents, setHandlesInput, setHeight, setHidden, setHidden, setHideInLandscape, setHideInPortrait, setIgnorePointerEvents, setInitialized, setInlineAllStyles, setInlineDisabledStyles, setInlinePressedStyles, setInlineSelectedStyles, setInlineStylesTheme, setInlineUnselectedStyles, setIsScrollVisible, setLabelForComponent, setName, setNextFocusDown, setNextFocusLeft, setNextFocusRight, setNextFocusUp, setOpaque, setOwner, setPinchBlocksDragAndDrop, setPreferredH, setPreferredSize, setPreferredSizeStr, setPreferredTabIndex, setPreferredW, setPressedStyle, setRippleEffect, setRTL, setSameHeight, setSameSize, setSameWidth, setScrollAnimationSpeed, setScrollOpacityChangeSpeed, setScrollSize, setScrollVisible, setScrollX, setScrollY, setSelectCommandText, setSelectedStyle, setSize, setSmoothScrolling, setSnapToGrid, setTabIndex, setTactileTouch, setTensileDragEnabled, setTensileLength, setTooltip, setTraversable, setUIID, setUIID, setUIIDFinal, setUnselectedStyle, setVisible, setWidth, setX, setY, shouldBlockSideSwipe, shouldBlockSideSwipeLeft, shouldBlockSideSwipeRight, shouldRenderComponentSelection, showNativeOverlay, startEditingAsync, stopEditing, stripMarginAndPadding, styleChanged, toImage, toString, unbindProperty, updateNativeOverlay, visibleBoundsContainsMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface Iterable
forEach, spliterator
-
Constructor Details
-
AutoCompleteTextComponent
public AutoCompleteTextComponent(ListModel<String> listModel, AutoCompleteTextComponent.AutoCompleteFilter customFilter) This constructor allows us to create an AutoCompleteTextComponent with the given listModel and customFilter
Parameters
-
listModel -
customFilter
-
-
-
Method Details
-
getField
Allows us to invoke setters/getters and bind listeners to the text field
Returns
the text field instance
- Overrides:
getFieldin classTextComponent
-
getEditor
Returns the editor component e.g. text field picker etc.
Returns
the editor component
- Overrides:
getEditorin classTextComponent
-
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
textComponentAnimBoolwhich is true by default on Android. Notice that this is designed for theonTopModeand might not work if that is set to false...Returns
true if the text should be on top
- Overrides:
isFocusAnimationin classTextComponent
-
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
textComponentAnimBoolwhich is true by default on Android. Notice that this is designed for theonTopModeand 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:
focusAnimationin classTextComponent
-
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:
textin classTextComponent
-
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
textComponentOnTopBooltheme constant which defaults to falseParameters
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:
onTopModein classTextComponent
-
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:
descriptionMessagein classTextComponent
-
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:
errorMessagein classTextComponent
-
label
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:
labelin classTextComponent
-
labelAndHint
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:
labelAndHintin classTextComponent
-
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:
hintin classTextComponent
-
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:
hintin classTextComponent
-
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:
multilinein classTextComponent
-
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:
columnsin classTextComponent
-
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:
rowsin classTextComponent
-
constraint
Sets the constraint for text input matching the constraints from the text area class
Parameters
constraint: @param constraint one of the constants from thecom.codename1.ui.TextAreaclass seecom.codename1.ui.TextArea#setConstraint(int)
Returns
this for chaining calls E.g.
AutoCompleteTextComponent tc = new AutoCompleteTextComponent().text("Text").label("Label");- Overrides:
constraintin classTextComponent
-
getAutoCompleteField
Allows us to invoke setters/getters and bind listeners to the text field
Returns
the text field instance
-
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:
getPropertyNamesin classTextComponent
-
getPropertyTypes
Matches the property names method (see that method for further details).
Returns
the types of the properties
- Overrides:
getPropertyTypesin classTextComponent
-
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:
getPropertyTypeNamesin classTextComponent
-
getPropertyValue
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:
getPropertyValuein classTextComponent
-
setPropertyValue
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:
setPropertyValuein classTextComponent
-
-
getText
Returns the text in the field
com.codename1.ui.TextArea#getText()Returns
the text
- Overrides:
getTextin classTextComponent
-