public class AutoCompleteTextField extends TextField
ANY, DECIMAL, EMAILADDR, INITIAL_CAPS_SENTENCE, INITIAL_CAPS_WORD, NON_PREDICTIVE, NUMERIC, PASSWORD, PHONENUMBER, SENSITIVE, UNEDITABLE, URL
BASELINE, BOTTOM, BRB_CENTER_OFFSET, BRB_CONSTANT_ASCENT, BRB_CONSTANT_DESCENT, BRB_OTHER, CENTER, 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, LEFT, RIGHT, TOP
Constructor and Description |
---|
AutoCompleteTextField()
The default constructor is useful for cases of filter subclasses overriding the
getSuggestionModel value as well as for the GUI builder
|
AutoCompleteTextField(ListModel<String> listModel)
Constructor with completion suggestions, filtering is automatic in this case
|
AutoCompleteTextField(String[] completion)
Constructor with completion suggestions
|
Modifier and Type | Method and Description |
---|---|
void |
addListListener(ActionListener a)
Adds an action listener that fires an event when an entry in the auto-complete list is selected.
|
protected void |
deinitialize()
Invoked to indicate that the component initialization is being reversed
since the component was detached from the container hierarchy.
|
protected boolean |
filter(String text)
Subclasses can override this method to perform more elaborate filter operations
|
int |
getMinimumLength()
Indicates the minimum length of text in the field in order for a popup to show
the default is 0 where a popup is shown immediately for all text length if the number
is 2 a popup will only appear when there are two characters or more.
|
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
|
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
|
Class[] |
getPropertyTypes()
Matches the property names method (see that method for further details).
|
Object |
getPropertyValue(String name)
Returns the current value of the property name, this method is used by the GUI builder
|
protected ListModel<String> |
getSuggestionModel()
Returns the list model to show within the completion list
|
protected void |
initComponent()
Allows subclasses to bind functionality that relies on fully initialized and
"ready for action" component state
|
boolean |
isStartsWithMode()
When enabled this makes the filter check that the string starts with rather than within the index
|
void |
keyPressed(int k)
If this Component is focused, the key pressed event
will call this method
|
void |
keyReleased(int k)
If this Component is focused, the key released event
will call this method
|
void |
removeListListener(ActionListener a)
Removes an action listener that fires an event when an entry in the auto-complete list is selected.
|
void |
setCompletionRenderer(ListCellRenderer completionRenderer)
Sets a custom renderer to the completion suggestions list.
|
void |
setMinimumLength(int minimumLength)
Indicates the minimum length of text in the field in order for a popup to show
the default is 0 where a popup is shown immediately for all text length if the number
is 2 a popup will only appear when there are two characters or more.
|
String |
setPropertyValue(String name,
Object value)
Sets a new value to the given property, returns an error message if failed
and null if successful.
|
void |
setStartsWithMode(boolean startsWithMode)
When enabled this makes the filter check that the string starts with rather than within the index
|
void |
setText(String text)
Sets the text within this text area
|
protected void |
updateFilterList()
In a case of an asynchronous filter this method can be invoked to refresh the completion list
|
addDataChangeListener, addInputMode, animate, calcPreferredSize, clear, commitChange, create, create, create, create, createSymbolTable, deleteChar, fireClicked, fireDataChanged, fireDoneEvent, getCharPerKeyCode, getCommitTimeout, getCursorBlinkTimeOff, getCursorBlinkTimeOn, getCursorPosition, getCursorX, getCursorY, getDefaultChangeInputModeKey, getDefaultInputModeOrder, getDefaultSymbolDialogKey, getDoneListener, getInputMode, getInputModeOrder, getLongClickDuration, getLongClickInputMode, getSymbolTable, insertChars, installCommands, isChangeInputMode, isClearKey, isCursorPositionCycle, isEditingEndTrigger, isEditingTrigger, isEnableInputScroll, isImmediateInputMode, isLeftAndRightEditingTrigger, isOverwriteMode, isPendingCommit, isQwertyAutoDetect, isQwertyDevice, isQwertyInput, isReplaceMenu, isReplaceMenuDefault, isSelectableInteraction, isSymbolDialogKey, isUseNativeTextInput, isUseSoftkeys, keyRepeated, longKeyPress, paint, pointerReleased, removeCommands, removeDataChangeListener, setAlignment, setClearText, setCommitTimeout, setCursorBlinkTimeOff, setCursorBlinkTimeOn, setCursorPosition, setDefaultChangeInputModeKey, setDefaultInputModeOrder, setDefaultSymbolDialogKey, setDoneListener, setEditable, setEnableInputScroll, setInputMode, setInputModeOrder, setLeftAndRightEditingTrigger, setOverwriteMode, setQwertyAutoDetect, setQwertyDevice, setQwertyInput, setReplaceMenu, setReplaceMenuDefault, setSymbolTable, setT9Text, setUseNativeTextInput, setUseSoftkeys, showSymbolDialog, validChar
addActionListener, autoDetectWidestChar, bindProperty, calcScrollSize, getAbsoluteAlignment, getActualRows, getAlignment, getBindablePropertyNames, getBindablePropertyTypes, getBoundPropertyValue, getColumns, getConstraint, getDefaultValign, getGrowLimit, getHint, getHintIcon, getHintLabel, getLines, getLinesToScroll, getMaxSize, getRows, getRowsGap, getText, getTextAt, getUnsupportedChars, getVerticalAlignment, getWidestChar, initLaf, isAutoDegradeMaxSize, isEditable, isEndsWith3Points, isEnterKey, isGrowByContent, isScrollableY, isSingleLineTextArea, isUseStringWidth, pointerHover, pointerHoverReleased, preprocess, removeActionListener, setAutoDegradeMaxSize, setBoundPropertyValue, setColumns, setConstraint, setDefaultMaxSize, setDefaultValign, setEndsWith3Points, setGrowByContent, setGrowLimit, setHint, setHint, setHintIcon, setLinesToScroll, setMaxSize, setRows, setRowsGap, setSingleLineTextArea, setUnsupportedChars, setUseStringWidth, setVerticalAlignment, setWidestChar, setWidth, unbindProperty
addDragOverListener, addDropListener, addFocusListener, addPointerDraggedListener, addPointerPressedListener, addPointerReleasedListener, addPullToRefresh, addScrollListener, cancelRepaints, clearClientProperties, contains, deinitializeCustomStyle, dragEnter, dragExit, draggingOver, dragInitiated, drawDraggedImage, drop, focusGained, focusLost, getAbsoluteX, getAbsoluteY, getBaseline, getBaselineResizeBehavior, getBorder, getBottomGap, getBounds, getClientProperty, getCloudBoundProperty, getCloudDestinationProperty, getComponentForm, getComponentState, getDirtyRegion, getDisabledStyle, getDraggedx, getDraggedy, getDragImage, getDragRegionStatus, getDragSpeed, getGridPosX, getGridPosY, getHeight, getLabelForComponent, getName, getNextFocusDown, getNextFocusLeft, getNextFocusRight, getNextFocusUp, getParent, getPreferredH, getPreferredSize, getPreferredW, getPressedStyle, getSameHeight, getSameWidth, getScrollable, getScrollAnimationSpeed, getScrollDimension, getScrollOpacity, getScrollOpacityChangeSpeed, getScrollX, getScrollY, getSelectCommandText, getSelectedRect, getSelectedStyle, getSideGap, getStyle, getTensileLength, getUIID, getUIManager, getUnselectedStyle, getVisibleBounds, getWidth, getX, getY, growShrink, handlesInput, hasFocus, initCustomStyle, installDefaultPainter, isAlwaysTensile, isCellRenderer, isDragActivated, isDragAndDropOperation, isDraggable, isDragRegion, isDropTarget, isEnabled, isFlatten, isFocusable, isGrabsPointerEvents, isHideInPortrait, isInClippingRegion, isInitialized, isRTL, isScrollable, isScrollableX, isScrollVisible, isSmoothScrolling, isSnapToGrid, isStickyDrag, isTactileTouch, isTactileTouch, isTensileDragEnabled, isVisible, laidOut, longPointerPress, onScrollX, onScrollY, paintBackground, paintBackgrounds, paintBorder, paintComponent, paintComponent, paintLock, paintLockRelease, paintScrollbars, paintScrollbarX, paintScrollbarY, paramString, pinch, pointerDragged, pointerDragged, pointerHoverPressed, pointerPressed, pointerPressed, pointerReleased, putClientProperty, refreshTheme, refreshTheme, refreshTheme, removeDragOverListener, removeDropListener, removeFocusListener, removePointerDraggedListener, removePointerPressedListener, removePointerReleasedListener, removeScrollListener, repaint, repaint, requestFocus, resetFocusable, scrollRectToVisible, scrollRectToVisible, setAlwaysTensile, setCellRenderer, setCloudBoundProperty, setCloudDestinationProperty, setComponentState, setDirtyRegion, setDisabledStyle, setDraggable, setDropTarget, setEnabled, setFlatten, setFocus, setFocusable, setGrabsPointerEvents, setHandlesInput, setHeight, setHideInPortrait, setInitialized, setIsScrollVisible, setLabelForComponent, setName, setNextFocusDown, setNextFocusLeft, setNextFocusRight, setNextFocusUp, setPreferredH, setPreferredSize, setPreferredW, setPressedStyle, setRTL, setSameHeight, setSameWidth, setScrollAnimationSpeed, setScrollOpacityChangeSpeed, setScrollSize, setScrollVisible, setScrollX, setScrollY, setSelectCommandText, setSelectedStyle, setShouldCalcPreferredSize, setSize, setSmoothScrolling, setSnapToGrid, setTactileTouch, setTensileDragEnabled, setTensileLength, setUIID, setUnselectedStyle, setVisible, setX, setY, shouldBlockSideSwipe, styleChanged, toString
public AutoCompleteTextField(String[] completion)
completion
- a String array of suggestion for completionpublic AutoCompleteTextField(ListModel<String> listModel)
listModel
- a list model containing potential string suggestionspublic AutoCompleteTextField()
protected void initComponent()
Component
initComponent
in class Component
protected void deinitialize()
Component
deinitialize
in class TextField
public void setText(String text)
TextArea
protected void updateFilterList()
protected boolean filter(String text)
text
- the text to filterprotected ListModel<String> getSuggestionModel()
public void setCompletionRenderer(ListCellRenderer completionRenderer)
completionRenderer
- a ListCellRenderer for the suggestions Listpublic void keyPressed(int k)
Component
keyPressed
in class TextField
k
- the key code value to indicate a physical key.public void keyReleased(int k)
Component
keyReleased
in class TextField
k
- the key code value to indicate a physical key.public void addListListener(ActionListener a)
a
- the listenerpublic void removeListListener(ActionListener a)
a
- the listenerpublic int getMinimumLength()
public void setMinimumLength(int minimumLength)
minimumLength
- the minimumLength to setpublic String[] getPropertyNames()
Component
getPropertyNames
in class Component
public Class[] getPropertyTypes()
Component
getPropertyTypes
in class Component
public String[] getPropertyTypeNames()
Component
getPropertyTypeNames
in class Component
public Object getPropertyValue(String name)
Component
getPropertyValue
in class Component
name
- the name of the propertypublic String setPropertyValue(String name, Object value)
Component
setPropertyValue
in class Component
name
- the name of the propertyvalue
- new value for the propertypublic boolean isStartsWithMode()
public void setStartsWithMode(boolean startsWithMode)
startsWithMode
- the startsWithMode to set