Class TextField
- All Implemented Interfaces:
Animation, Editable, ActionSource, StyleListener, TextHolder
- Direct Known Subclasses:
AutoCompleteTextField
A specialized version of com.codename1.ui.TextArea with some minor deviations from the original
specifically:
-
Blinking cursor is rendered on
TextFieldonly -
com.codename1.ui.events.DataChangeListeneris only available inTextField. This is crucial for character by character input event tracking -
com.codename1.ui.TextField#setDoneListener(com.codename1.ui.events.ActionListener)is only available inTextField -
Different UIID's ("
TextField" vs. "TextArea")
The demo code below shows simple input using text fields:
TableLayout tl;
int spanButton = 2;
if(Display.getInstance().isTablet()) {
tl = new TableLayout(7, 2);
} else {
tl = new TableLayout(14, 1);
spanButton = 1;
}
tl.setGrowHorizontally(true);
hi.setLayout(tl);
TextField firstName = new TextField("", "First Name", 20, TextArea.ANY);
TextField surname = new TextField("", "Surname", 20, TextArea.ANY);
TextField email = new TextField("", "E-Mail", 20, TextArea.EMAILADDR);
TextField url = new TextField("", "URL", 20, TextArea.URL);
TextField phone = new TextField("", "Phone", 20, TextArea.PHONENUMBER);
TextField num1 = new TextField("", "1234", 4, TextArea.NUMERIC);
TextField num2 = new TextField("", "1234", 4, TextArea.NUMERIC);
TextField num3 = new TextField("", "1234", 4, TextArea.NUMERIC);
TextField num4 = new TextField("", "1234", 4, TextArea.NUMERIC);
Button submit = new Button("Submit");
TableLayout.Constraint cn = tl.createConstraint();
cn.setHorizontalSpan(spanButton);
cn.setHorizontalAlign(Component.RIGHT);
hi.add("First Name").add(firstName).
add("Surname").add(surname).
add("E-Mail").add(email).
add("URL").add(url).
add("Phone").add(phone).
add("Credit Card").
add(GridLayout.encloseIn(4, num1, num2, num3, num4)).
add(cn, submit);
The following code demonstrates a more advanced search widget where the data is narrowed as we type
directly into the title area search. Notice that the TextField and its hint are styled to look like the title.
Toolbar.setGlobalToolbar(true);
Style s = UIManager.getInstance().getComponentStyle("Title");
Form hi = new Form("Toolbar", new BoxLayout(BoxLayout.Y_AXIS));
TextField searchField = new TextField("", "Toolbar Search"); //
searchField.getHintLabel().setUIID("Title");
searchField.setUIID("Title");
searchField.getAllStyles().setAlignment(Component.LEFT);
hi.getToolbar().setTitleComponent(searchField);
FontImage searchIcon = FontImage.createMaterial(FontImage.MATERIAL_SEARCH, s);
searchField.addDataChangeListener((i1, i2) -> { //
String t = searchField.getText();
if(t.length() -1;
cmp.setHidden(!show); //
cmp.setVisible(show);
}
}
hi.getContentPane().animateLayout(250);
});
hi.getToolbar().addCommandToRightBar("", searchIcon, (e) -> {
searchField.startEditingAsync(); //
});
hi.add("A Game of Thrones").
add("A Clash Of Kings").
add("A Storm Of Swords").
add("A Feast For Crows").
add("A Dance With Dragons").
add("The Winds of Winter").
add("A Dream of Spring");
hi.show();
-
Field Summary
Fields inherited from class TextArea
ANY, DECIMAL, EMAILADDR, INITIAL_CAPS_SENTENCE, INITIAL_CAPS_WORD, NON_PREDICTIVE, NUMERIC, PASSWORD, PHONENUMBER, SENSITIVE, UNEDITABLE, UPPERCASE, URL, USERNAMEFields 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
ConstructorsConstructorDescriptionDefault constructorTextField(int columns) Construct a text field with space reserved for columnsConstruct text fieldConstruct text fieldConstruct text field with a hintConstruct text field with a hint, columns and constraint values -
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddInputMode(String name, Hashtable values, boolean firstUpcase) Adds a new inputmode hashtable with the given name and set of valuesbooleananimate()Allows the animation to reduce "repaint" calls when it returns false.protected DimensionCalculates the preferred size based on component content.protected TextSelection.SpansCalculates the spans for the the given text selection.voidclear()Clears the text from the TextFieldprotected voidCommit the changes made to the text field as a complete edit operation.static TextAreacreate()Default factory methodstatic TextAreacreate(int columns) Construct text field/area depending on whether native in place editing is supportedstatic TextAreaConstruct text field/area depending on whether native in place editing is supportedstatic TextAreaConstruct text field/area depending on whether native in place editing is supportedprotected ContainerCreates a symbol table container used by the showSymbolDialog method.protected voidInvoked to indicate that the component initialization is being reversed since the component was detached from the container hierarchy.voidPerforms a backspace operationprotected voidWhen working in 3 softbutton mode "fire" key (center softbutton) is sent to this method in order to allow 3 button devices to work properly.protected chargetCharPerKeyCode(int pressCount, int keyCode, boolean longClick) Returns the character matching the given key code after the given amount of user pressesintThe amount of time in milliseconds it will take for a change to get committed into the field.intThe amount of time in milliseconds in which the cursor is invisibleintThe amount of time in milliseconds in which the cursor is visibleintReturns the position of the cursor char positionintReturns the position of the cursor char position in the current line.intReturns the position of the cursor line positionstatic intKey to change the input mode on the devicestatic String[]Returns the order in which input modes are toggled by defaultstatic intThe default key for poping open the symbol dialogReturns the currently selected input modeString[]Returns the order in which input modes are toggledprotected intThe amount of time considered as a "long click" causing the long click method to be invoked.protected StringReturns the input mode for the ong click modestatic char[]Returns the symbol table for the devicevoidThis method is responsible for adding a character into the field and is the focal point for all input.protected CommandinstallCommands(Command clear, Command t9) Installs the clear and t9 commands onto the parent form, this method can be overriden to provide device specific placement for these commandsprotected booleanisChangeInputMode(int keyCode) Indicates whether the key changes the current input modeprotected booleanisClearKey(int keyCode) Returns true if this is the clear key on the device, many devices don't contain a clear key and even in those that contain it this might be an issueprotected booleanReturns true if the cursor should cycle to the beginning of the text when the user navigates beyond the edge of the text and visa versa.protected booleanisEditingEndTrigger(int keyCode) Indicates whether the given key code should be ignored or should trigger cause editing to end.protected booleanisEditingTrigger(int keyCode) Indicates whether the given key code should be ignored or should trigger editing, by default fire or any numeric key should trigger editing implicitly.booleanIndicates whether text field input should scroll to the right side when no more room for the input is present.protected booleanisImmediateInputMode(String mode) Returns true if the given input mode should commit immediately or wait for the commit timeoutbooleanIndicates whether the left/right keys will trigger editing, this is true by default.booleanIndicates that this is the overwrite modebooleanReturns true if the text field is waiting for a commit on editingstatic booleanIndicates whether the text field should try to auto detect qwerty and switch the qwerty device flag implicitlystatic booleanThe default value for the qwerty flag so it doesn't need setting for every text field individually.booleanTrue is this is a qwerty device or a device that is currently in qwerty mode.booleanIndicates whether the menu of the form should be replaced with the T9/Clear commands for the duration of interactivity with the text fieldstatic booleanIndicates whether the menu of the form should be replaced with the T9/Clear commands for the duration of interactivity with the text fieldprotected booleanThis method allows a component to indicate that it is interested in an "implicit" select command to appear in the "fire" button when 3 softbuttons are defined in a device.protected booleanisSymbolDialogKey(int keyCode) Returns true if this keycode is the one mapping to the symbol dialog popupstatic booleanIndicates that native text input should be used in text field when in place editing is supported by the platformbooleanWhen set to true softkeys are used to enable delete functionalityvoidkeyPressed(int keyCode) If this Component is focused, the key pressed event will call this methodvoidkeyReleased(int keyCode) If this Component is focused, the key released event will call this methodvoidkeyRepeated(int keyCode) If this Component is focused, the key repeat event will call this method.protected voidlongKeyPress(int keyCode) If this Component is focused this method is invoked when the user presses and holds the keyvoidThis method paints the Component on the screen, it should be overriden by subclasses to perform custom drawing or invoke the UI API's to let the PLAF perform the rendering.voidpointerReleased(int x, int y) If this Component is focused, the pointer released event will call this methodprotected voidremoveCommands(Command clear, Command t9, Command originalClear) Removes the clear and t9 commands from the parent form, this method can be overriden to provide device specific placement for these commandsvoidsetAlignment(int align) Sets the Alignment of the TextArea to one of: CENTER, LEFT, RIGHTstatic voidsetClearText(String text) Set the text that should appear on the clear softkeyvoidsetCommitTimeout(int commitTimeout) The amount of time in milliseconds it will take for a change to get committed into the field.voidsetCursorBlinkTimeOff(int time) The amount of time in milliseconds in which the cursor is invisiblevoidsetCursorBlinkTimeOn(int time) The amount of time in milliseconds in which the cursor is visiblevoidsetCursorPosition(int pos) Sets the position of the cursor char positionstatic voidsetDefaultChangeInputModeKey(int k) Key to change the input mode on the devicestatic voidsetDefaultInputModeOrder(String[] order) Sets the order in which input modes are toggled by default and allows disabling/hiding an input modestatic voidsetDefaultSymbolDialogKey(int d) The default key for poping open the symbol dialogvoidsetEditable(boolean b) Sets this text area to be editable or readonlyvoidsetEnableInputScroll(boolean enableInputScroll) Indicates whether text field input should scroll to the right side when no more room for the input is present.voidsetInputMode(String inputMode) Sets the current selected input mode matching one of the existing input modesvoidsetInputModeOrder(String[] order) Sets the order in which input modes are toggled and allows disabling/hiding an input modevoidsetLeftAndRightEditingTrigger(boolean leftAndRightEditingTrigger) Indicates whether the left/right keys will trigger editing, this is true by default.voidsetOverwriteMode(boolean overwriteMode) Indicates that this is the overwrite modestatic voidsetQwertyAutoDetect(boolean v) Indicates whether the text field should try to auto detect qwerty and switch the qwerty device flag implicitlystatic voidsetQwertyDevice(boolean v) The default value for the qwerty flag so it doesn't need setting for every text field individually.voidsetQwertyInput(boolean qwerty) True is this is a qwerty device or a device that is currently in qwerty mode.voidsetReplaceMenu(boolean replaceMenu) Indicates whether the menu of the form should be replaced with the T9/Clear commands for the duration of interactivity with the text fieldstatic voidsetReplaceMenuDefault(boolean replaceMenu) Indicates whether the menu of the form should be replaced with the T9/Clear commands for the duration of interactivity with the text fieldstatic voidsetSymbolTable(char[] table) Sets the symbol table to show when the user clicks the symbol table keystatic voidSet the text that should appear on the T9 softkeyvoidSets the text within this text areastatic voidsetUseNativeTextInput(boolean aUseNativeTextInput) Indicates that native text input should be used in text field when in place editing is supported by the platformvoidsetUseSoftkeys(boolean useSoftkeys) When set to true softkeys are used to enable delete functionalityprotected voidInvoked to show the symbol dialog, this method can be overriden by subclasses to manipulate the symbol tablebooleanChecks if the candidate input is valid for this TextFieldMethods inherited from class TextArea
addActionListener, addCloseListener, addDataChangedListener, addDataChangeListener, autoDetectWidestChar, bindProperty, calcScrollSize, fireDataChanged, fireDoneEvent, fireDoneEvent, getAbsoluteAlignment, getActualRows, getAlignment, getAsDouble, getAsInt, getAsLong, getBindablePropertyNames, getBindablePropertyTypes, getBoundPropertyValue, getColumns, getConstraint, getDefaultValign, getDoneListener, getGrowLimit, getHint, getHintIcon, getHintLabel, getLines, getLinesToScroll, getMaxSize, getPreferredTabIndex, getRows, getRowsGap, getStyle, getText, getTextAt, getTextSelectionSupport, getUnsupportedChars, getVerticalAlignment, getWidestChar, initComponent, initLaf, isActAsLabel, isAutoDegradeMaxSize, isEditable, isEditing, isEndsWith3Points, isEnterKey, isGrowByContent, isScrollableY, isSingleLineTextArea, isTextSelectionEnabled, isUseStringWidth, pointerHover, pointerHoverReleased, preprocess, registerAsInputDevice, removeActionListener, removeCloseListener, removeDataChangedListener, removeDataChangeListener, setActAsLabel, setAutoDegradeMaxSize, setBoundPropertyValue, setColumns, setConstraint, setDefaultMaxSize, setDefaultValign, setDoneListener, setEndsWith3Points, setGrowByContent, setGrowLimit, setHint, setHint, setHintIcon, setLinesToScroll, setMaxSize, setRows, setRowsGap, setSingleLineTextArea, setTextSelectionEnabled, setUnsupportedChars, setUseStringWidth, setVerticalAlignment, setWidestChar, setWidth, shouldRenderComponentSelection, startEditing, startEditingAsync, stopEditing, stopEditing, unbindPropertyMethods inherited from class Component
addDragFinishedListener, addDragOverListener, addDropListener, addFocusListener, addLongPressListener, addPointerDraggedListener, addPointerPressedListener, addPointerReleasedListener, addPullToRefresh, addScrollListener, addStateChangeListener, announceForAccessibility, blocksSideSwipe, cancelRepaints, clearClientProperties, contains, containsOrOwns, createStyleAnimation, deinitializeCustomStyle, dragEnter, dragExit, dragFinished, draggingOver, dragInitiated, drawDraggedImage, drop, focusGained, focusLost, getAbsoluteX, getAbsoluteY, getAccessibilityText, getAllStyles, getAnimationManager, getBaseline, getBaselineResizeBehavior, getBorder, getBottomGap, getBounds, getBounds, getClientProperty, getCloudBoundProperty, getCloudDestinationProperty, getComponentForm, getComponentState, getCursor, getDefaultDragTransparency, getDirtyRegion, getDisabledStyle, getDraggedx, getDraggedy, getDragImage, getDragRegionStatus, getDragSpeed, getDragTransparency, getEditingDelegate, getGridPosX, getGridPosY, 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, getPreferredW, getPressedStyle, getPropertyNames, getPropertyTypeNames, getPropertyTypes, getPropertyValue, getSameHeight, getSameWidth, getScrollable, getScrollAnimationSpeed, getScrollDimension, getScrollOpacity, getScrollOpacityChangeSpeed, getScrollX, getScrollY, getSelectCommandText, getSelectedRect, getSelectedStyle, getSideGap, getTabIndex, getTensileLength, getTooltip, getUIID, getUIManager, getUnselectedStyle, getVisibleBounds, getVisibleBounds, getWidth, getX, getY, growShrink, handlesInput, hasFixedPreferredSize, hasFocus, hideNativeOverlay, initCustomStyle, initDisabledStyle, initPressedStyle, initSelectedStyle, initUnselectedStyle, installDefaultPainter, isAlwaysTensile, isBlockLead, isCellRenderer, isChildOf, isDragActivated, isDragAndDropOperation, isDraggable, isDragRegion, isDropTarget, isEnabled, isFlatten, isFocusable, isGrabsPointerEvents, isHidden, isHidden, isHideInLandscape, isHideInPortrait, isIgnorePointerEvents, isInClippingRegion, isInitialized, isOpaque, isOwnedBy, isPinchBlocksDragAndDrop, isRippleEffect, isRTL, isScrollable, isScrollableX, isScrollVisible, isSetCursorSupported, isSmoothScrolling, isSnapToGrid, isStickyDrag, isTactileTouch, isTactileTouch, isTensileDragEnabled, isTraversable, isVisible, laidOut, longPointerPress, onScrollX, onScrollY, onSetFocusable, paintBackground, paintBackgrounds, paintBorder, paintBorderBackground, paintComponent, paintComponent, paintIntersectingComponentsAbove, paintLock, paintLockRelease, paintRippleOverlay, paintScrollbars, paintScrollbarX, paintScrollbarY, paintShadows, paramString, parsePreferredSize, pinch, pinch, pinchReleased, pointerDragged, pointerDragged, pointerHoverPressed, pointerPressed, pointerPressed, pointerReleased, putClientProperty, refreshTheme, refreshTheme, refreshTheme, remove, removeDragFinishedListener, removeDragOverListener, removeDropListener, removeFocusListener, removeLongPressListener, removePointerDraggedListener, removePointerPressedListener, removePointerReleasedListener, removeScrollListener, removeStateChangeListener, repaint, repaint, requestFocus, resetFocusable, respondsToPointerEvents, scrollRectToVisible, scrollRectToVisible, setAccessibilityText, setAlwaysTensile, setBlockLead, setCellRenderer, setCloudBoundProperty, setCloudDestinationProperty, setComponentState, setCursor, setDefaultDragTransparency, setDirtyRegion, setDisabledStyle, setDraggable, setDragTransparency, setDropTarget, setEditingDelegate, setEnabled, 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, setPropertyValue, setRippleEffect, setRTL, setSameHeight, setSameSize, setSameWidth, setScrollAnimationSpeed, setScrollOpacityChangeSpeed, setScrollSize, setScrollVisible, setScrollX, setScrollY, setSelectCommandText, setSelectedStyle, setShouldCalcPreferredSize, setSize, setSmoothScrolling, setSnapToGrid, setTabIndex, setTactileTouch, setTensileDragEnabled, setTensileLength, setTooltip, setTraversable, setUIID, setUIID, setUIIDFinal, setUnselectedStyle, setVisible, setX, setY, shouldBlockSideSwipe, shouldBlockSideSwipeLeft, shouldBlockSideSwipeRight, showNativeOverlay, stripMarginAndPadding, styleChanged, toImage, toString, updateNativeOverlay, visibleBoundsContains
-
Constructor Details
-
TextField
public TextField()Default constructor -
TextField
public TextField(int columns) Construct a text field with space reserved for columns
Parameters
columns: - the number of columns
-
TextField
Construct text field
Parameters
text: the text of the field
-
TextField
-
TextField
-
TextField
Construct text field
Parameters
-
text: the text of the field -
columns: - the number of columns
-
-
-
Method Details
-
isUseNativeTextInput
public static boolean isUseNativeTextInput()Indicates that native text input should be used in text field when in place editing is supported by the platform
Returns
the useNativeTextInput
Deprecated
this API is no longer useful and should be avoided
-
setUseNativeTextInput
public static void setUseNativeTextInput(boolean aUseNativeTextInput) Indicates that native text input should be used in text field when in place editing is supported by the platform
Parameters
aUseNativeTextInput: the useNativeTextInput to set
Deprecated
this API is no longer useful and should be avoided
-
setClearText
Set the text that should appear on the clear softkey
Parameters
text: localized text for the clear softbutton
-
setT9Text
Set the text that should appear on the T9 softkey
Parameters
text: text for the T9 softbutton
-
create
-
create
Default factory method
Returns
a text field if native in place editing is unsupported and a text area if it is
-
create
Construct text field/area depending on whether native in place editing is supported
Parameters
columns: - the number of columns
Returns
a text field if native in place editing is unsupported and a text area if it is
-
create
-
addInputMode
Adds a new inputmode hashtable with the given name and set of values
Parameters
-
name: a unique display name for the input mode e.g. ABC, 123 etc... -
values: @param values The key for the hashtable is an Integer keyCode and the value is a String containing the characters to toggle between for the given keycode -
firstUpcase: @param firstUpcase indicates if this input mode in an input mode used for the special case where the first letter is an upper case letter
Deprecated
this is a method for use only on old J2ME devices and is ignored everywhere else
-
-
getDefaultInputModeOrder
Returns the order in which input modes are toggled by default
Returns
the default order of the input mode
Deprecated
this is a method for use only on old J2ME devices and is ignored everywhere else
-
setDefaultInputModeOrder
Sets the order in which input modes are toggled by default and allows disabling/hiding an input mode
Parameters
order: the order for the input modes in all future created fields
Deprecated
this is a method for use only on old J2ME devices and is ignored everywhere else
-
getSymbolTable
public static char[] getSymbolTable()Returns the symbol table for the device
Returns
the symbol table of the device for the symbol table input
-
setSymbolTable
public static void setSymbolTable(char[] table) Sets the symbol table to show when the user clicks the symbol table key
Parameters
table: the symbol table of the device for the symbol table input
-
isReplaceMenuDefault
public static boolean isReplaceMenuDefault()Indicates whether the menu of the form should be replaced with the T9/Clear commands for the duration of interactivity with the text field
Returns
true if the menu should be replaced
-
setReplaceMenuDefault
public static void setReplaceMenuDefault(boolean replaceMenu) Indicates whether the menu of the form should be replaced with the T9/Clear commands for the duration of interactivity with the text field
Parameters
replaceMenu: true if the menu should be replaced
-
isQwertyAutoDetect
public static boolean isQwertyAutoDetect()Indicates whether the text field should try to auto detect qwerty and switch the qwerty device flag implicitly
Returns
true for qwerty auto detection
-
setQwertyAutoDetect
public static void setQwertyAutoDetect(boolean v) Indicates whether the text field should try to auto detect qwerty and switch the qwerty device flag implicitly
Parameters
v: true for qwerty auto detection
-
isQwertyDevice
public static boolean isQwertyDevice()The default value for the qwerty flag so it doesn't need setting for every text field individually.
Returns
true for qwerty devices
-
setQwertyDevice
public static void setQwertyDevice(boolean v) The default value for the qwerty flag so it doesn't need setting for every text field individually.
Parameters
v: true for qwerty device
-
getDefaultChangeInputModeKey
public static int getDefaultChangeInputModeKey()Key to change the input mode on the device
Returns
key to change the input mode
Deprecated
this is a method for use only on old J2ME devices and is ignored everywhere else
-
setDefaultChangeInputModeKey
public static void setDefaultChangeInputModeKey(int k) Key to change the input mode on the device
Parameters
k: key to change the input mode
Deprecated
this is a method for use only on old J2ME devices and is ignored everywhere else
-
getDefaultSymbolDialogKey
public static int getDefaultSymbolDialogKey()The default key for poping open the symbol dialog
Returns
the default key
-
setDefaultSymbolDialogKey
public static void setDefaultSymbolDialogKey(int d) The default key for poping open the symbol dialog
Parameters
d: new key value
-
isEnableInputScroll
public boolean isEnableInputScroll()Indicates whether text field input should scroll to the right side when no more room for the input is present.
Returns
true if scrolling is enabled
- Overrides:
isEnableInputScrollin classTextArea
-
setEnableInputScroll
public void setEnableInputScroll(boolean enableInputScroll) Indicates whether text field input should scroll to the right side when no more room for the input is present.
Parameters
enableInputScroll: true to enable scrolling to the side
-
deleteChar
public void deleteChar()Performs a backspace operation -
commitChange
protected void commitChange()Commit the changes made to the text field as a complete edit operation. This is used in a numeric keypad to allow the user to repeatedly press a number to change values. -
isPendingCommit
public boolean isPendingCommit()Returns true if the text field is waiting for a commit on editing
Returns
true if a commit is pending
- Overrides:
isPendingCommitin classTextArea
-
getCommitTimeout
public int getCommitTimeout()The amount of time in milliseconds it will take for a change to get committed into the field.
Returns
the time for a commit timeout
-
setCommitTimeout
public void setCommitTimeout(int commitTimeout) The amount of time in milliseconds it will take for a change to get committed into the field.
Parameters
commitTimeout: @param commitTimeout indicates the amount of time that should elapse for a commit to automatically occur
-
getInputMode
Returns the currently selected input mode
Returns
Deprecated
this is a method for use only on old J2ME devices and is ignored everywhere else
- Overrides:
getInputModein classTextArea- Returns:
- the display name of the input mode by default the following modes are supported: Abc, ABC, abc, 123
-
setInputMode
Sets the current selected input mode matching one of the existing input modes
Parameters
inputMode: @param inputMode the display name of the input mode by default the following modes are supported: Abc, ABC, abc, 123
Deprecated
this is a method for use only on old J2ME devices and is ignored everywhere else
-
isChangeInputMode
protected boolean isChangeInputMode(int keyCode) Indicates whether the key changes the current input mode
Parameters
keyCode: the code
Returns
true for the hash (#) key code
Deprecated
this is a method for use only on old J2ME devices and is ignored everywhere else
-
getInputModeOrder
Returns the order in which input modes are toggled
Returns
the order of the input modes
- Overrides:
getInputModeOrderin classTextArea
-
setInputModeOrder
Sets the order in which input modes are toggled and allows disabling/hiding an input mode
Parameters
order: the order for the input modes in this field
Deprecated
this is a method for use only on old J2ME devices and is ignored everywhere else
-
getLongClickInputMode
Returns the input mode for the ong click mode
Returns
returns 123 by default
-
getCharPerKeyCode
protected char getCharPerKeyCode(int pressCount, int keyCode, boolean longClick) Returns the character matching the given key code after the given amount of user presses
Parameters
-
pressCount: number of times this keycode was pressed -
keyCode: the actual keycode input by the user -
longClick: does this click constitute a long click
Returns
- Returns:
- the char mapping to this key or 0 if no appropriate char was found (navigation, input mode change etc...).
-
-
getCursorPosition
public int getCursorPosition()Returns the position of the cursor char position
Returns
the cursor position
- Overrides:
getCursorPositionin classTextArea
-
setCursorPosition
public void setCursorPosition(int pos) Sets the position of the cursor char position
Parameters
pos: the cursor position
-
getCursorY
public int getCursorY()Returns the position of the cursor line position
Returns
the cursor line position
- Overrides:
getCursorYin classTextArea
-
getCursorX
public int getCursorX()Returns the position of the cursor char position in the current line.
Returns
the cursor char position in the current line
- Overrides:
getCursorXin classTextArea
-
setText
Sets the text within this text area
Parameters
t: new value for the text area
- Specified by:
setTextin interfaceTextHolder- Overrides:
setTextin classTextArea
-
clear
public void clear()Clears the text from the TextField -
isClearKey
protected boolean isClearKey(int keyCode) Returns true if this is the clear key on the device, many devices don't contain a clear key and even in those that contain it this might be an issue
Parameters
keyCode: the key code that might be the clear key
Returns
true if this is the clear key.
-
longKeyPress
protected void longKeyPress(int keyCode) If this Component is focused this method is invoked when the user presses and holds the key
Parameters
keyCode: the key code value to indicate a physical key.
- Overrides:
longKeyPressin classComponent
-
isQwertyInput
public boolean isQwertyInput()True is this is a qwerty device or a device that is currently in qwerty mode.
Returns
currently defaults to false
- Overrides:
isQwertyInputin classTextArea
-
setQwertyInput
public void setQwertyInput(boolean qwerty) True is this is a qwerty device or a device that is currently in qwerty mode.
Parameters
qwerty: the value of qwerty mode
-
isImmediateInputMode
Returns true if the given input mode should commit immediately or wait for the commit timeout
Parameters
mode: the input mode
Returns
returns true for input mode 123 by default
Deprecated
this is a method for use only on old J2ME devices and is ignored everywhere else
-
insertChars
This method is responsible for adding a character into the field and is the focal point for all input. It can be overriden to prevent a particular char from insertion or provide a different behavior for char insertion. It is the responsibility of this method to shift the cursor and invoke setText...
This method accepts a string for the more elaborate cases such as multi-char input and paste.
Parameters
c: character for insertion
Deprecated
this is a method for use only on old J2ME devices and is ignored everywhere else
-
validChar
Checks if the candidate input is valid for this TextField
Parameters
c: the String to insert
Returns
true if the String is valid
-
showSymbolDialog
protected void showSymbolDialog()Invoked to show the symbol dialog, this method can be overriden by subclasses to manipulate the symbol table -
createSymbolTable
Creates a symbol table container used by the showSymbolDialog method. This method is designed for subclases to override and customize.
Returns
container for the symbol table.
-
keyReleased
public void keyReleased(int keyCode) If this Component is focused, the key released event will call this method
Parameters
keyCode: the key code value to indicate a physical key.
- Overrides:
keyReleasedin classTextArea
-
getLongClickDuration
protected int getLongClickDuration()The amount of time considered as a "long click" causing the long click method to be invoked.
Returns
currently defaults to 800
-
isCursorPositionCycle
protected boolean isCursorPositionCycle()Returns true if the cursor should cycle to the beginning of the text when the user navigates beyond the edge of the text and visa versa.
Returns
true by default
-
isSymbolDialogKey
protected boolean isSymbolDialogKey(int keyCode) Returns true if this keycode is the one mapping to the symbol dialog popup
Parameters
keyCode: the keycode to check
Returns
true if this is the star symbol *
-
deinitialize
protected void deinitialize()Invoked to indicate that the component initialization is being reversed since the component was detached from the container hierarchy. This allows the component to deregister animators and cleanup after itself. This method is the opposite of the initComponent() method.- Overrides:
deinitializein classTextArea
-
setEditable
public void setEditable(boolean b) Sets this text area to be editable or readonly
Parameters
b: true is text are is editable; otherwise false
- Overrides:
setEditablein classTextArea
-
keyRepeated
public void keyRepeated(int keyCode) If this Component is focused, the key repeat event will call this method.
Parameters
keyCode: the key code value to indicate a physical key.
- Overrides:
keyRepeatedin classComponent
-
keyPressed
public void keyPressed(int keyCode) If this Component is focused, the key pressed event will call this method
Parameters
keyCode: the key code value to indicate a physical key.
- Overrides:
keyPressedin classTextArea
-
installCommands
Installs the clear and t9 commands onto the parent form, this method can be overriden to provide device specific placement for these commands
Parameters
-
clear: the clear command -
t9: the t9 command
Returns
- Returns:
- clear command already installed in the form if applicable, none if no clear command was installed before or not applicable.
-
-
isSelectableInteraction
protected boolean isSelectableInteraction()This method allows a component to indicate that it is interested in an "implicit" select command to appear in the "fire" button when 3 softbuttons are defined in a device.
Returns
true if this is a selectable interaction
- Overrides:
isSelectableInteractionin classTextArea
-
fireClicked
protected void fireClicked()When working in 3 softbutton mode "fire" key (center softbutton) is sent to this method in order to allow 3 button devices to work properly. When overriding this method you should also override isSelectableInteraction to indicate that a command is placed appropriately on top of the fire key for 3 soft button phones.- Overrides:
fireClickedin classTextArea
-
removeCommands
Removes the clear and t9 commands from the parent form, this method can be overriden to provide device specific placement for these commands
Parameters
-
clear: the clear command -
t9: the t9 command -
originalClear: the command originally assigned as the clear command (or null if no command was assigned before)
-
-
isEditingTrigger
protected boolean isEditingTrigger(int keyCode) Indicates whether the given key code should be ignored or should trigger editing, by default fire or any numeric key should trigger editing implicitly. This method is only called when handles input is false.
Parameters
keyCode: the keycode passed to the keyPressed method
Returns
true if this key code should cause a switch to editing mode.
-
isEditingEndTrigger
protected boolean isEditingEndTrigger(int keyCode) Indicates whether the given key code should be ignored or should trigger cause editing to end. By default the fire key, up or down will trigger the end of editing.
Parameters
keyCode: the keycode passed to the keyPressed method
Returns
true if this key code should cause a switch to editing mode.
-
paint
This method paints the Component on the screen, it should be overriden by subclasses to perform custom drawing or invoke the UI API's to let the PLAF perform the rendering.
Parameters
g: the component graphics
-
calcPreferredSize
Calculates the preferred size based on component content. This method is invoked lazily by getPreferred size.
Returns
the calculated preferred size based on component content
- Overrides:
calcPreferredSizein classTextArea
-
getCursorBlinkTimeOn
public int getCursorBlinkTimeOn()The amount of time in milliseconds in which the cursor is visible
Returns
time for the cursor to stay "on"
-
setCursorBlinkTimeOn
public void setCursorBlinkTimeOn(int time) The amount of time in milliseconds in which the cursor is visible
Parameters
time: for the cursor to stay "on"
-
getCursorBlinkTimeOff
public int getCursorBlinkTimeOff()The amount of time in milliseconds in which the cursor is invisible
Returns
time for the cursor to stay "off"
-
setCursorBlinkTimeOff
public void setCursorBlinkTimeOff(int time) The amount of time in milliseconds in which the cursor is invisible
Parameters
time: for the cursor to stay "off"
-
animate
public boolean animate()Allows the animation to reduce "repaint" calls when it returns false. It is called once for every frame. Frames are defined by the
com.codename1.ui.Displayclass.Returns
true if a repaint is desired or false if no repaint is necessary
-
pointerReleased
public void pointerReleased(int x, int y) If this Component is focused, the pointer released event will call this method
Parameters
-
x: the pointer x coordinate -
y: the pointer y coordinate
- Overrides:
pointerReleasedin classTextArea
-
-
isUseSoftkeys
public boolean isUseSoftkeys()When set to true softkeys are used to enable delete functionality
Returns
true if softkeys should be used
-
setUseSoftkeys
public void setUseSoftkeys(boolean useSoftkeys) When set to true softkeys are used to enable delete functionality
Parameters
useSoftkeys: true if softkeys should be used
-
isReplaceMenu
public boolean isReplaceMenu()Indicates whether the menu of the form should be replaced with the T9/Clear commands for the duration of interactivity with the text field
Returns
true if the menu should be replaced
-
setReplaceMenu
public void setReplaceMenu(boolean replaceMenu) Indicates whether the menu of the form should be replaced with the T9/Clear commands for the duration of interactivity with the text field
Parameters
replaceMenu: true if the menu should be replaced
-
isOverwriteMode
public boolean isOverwriteMode()Indicates that this is the overwrite mode
Returns
true if input with overwrite characters
-
setOverwriteMode
public void setOverwriteMode(boolean overwriteMode) Indicates that this is the overwrite mode
Parameters
overwriteMode: set to true if input with overwrite characters
-
isLeftAndRightEditingTrigger
public boolean isLeftAndRightEditingTrigger()Indicates whether the left/right keys will trigger editing, this is true by default. Left and right key edit trigger might be disabled for cases such as text field positioned horizontally one next to the other.
Returns
leftAndRightEditingTrigger Indicates whether the left/right keys will trigger editing
-
setLeftAndRightEditingTrigger
public void setLeftAndRightEditingTrigger(boolean leftAndRightEditingTrigger) Indicates whether the left/right keys will trigger editing, this is true by default. Left and right key edit trigger might be disabled for cases such as text field positioned horizontally one next to the other.
Parameters
leftAndRightEditingTrigger: Indicates whether the left/right keys will trigger editing
-
setAlignment
public void setAlignment(int align) Sets the Alignment of the TextArea to one of: CENTER, LEFT, RIGHT
Parameters
align: alignment value
Deprecated
use Style.setAlignment instead
See also
-
#CENTER
-
#LEFT
-
#RIGHT
- Overrides:
setAlignmentin classTextArea
-
calculateTextSelectionSpan
Calculates the spans for the the given text selection. This should generally just delegate to the appropriate method in the look and feel for performing the layout calculation.
Parameters
sel: The TextSelection
Since
7.0
- Overrides:
calculateTextSelectionSpanin classTextArea
-