public class TextField extends TextArea
Notice that due to limitations of text area and text field input modes in text area aren't properly supported since they won't work properly across devices. To limit input modes please use the setInputModeOrder method. All constants declared in TextArea are ignored with the exception of PASSWORD.
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 |
---|
TextField()
Default constructor
|
TextField(int columns)
Construct a text field with space reserved for columns
|
TextField(String text)
Construct text field
|
TextField(String text,
int columns)
Construct text field
|
Modifier and Type | Method and Description |
---|---|
void |
addDataChangeListener(DataChangedListener d)
Adds a listener for data change events it will be invoked for every change
made to the text field, notice most platforms will invoke only the
DataChangedListener.CHANGED event
|
static void |
addInputMode(String name,
Hashtable values,
boolean firstUpcase)
Adds a new inputmode hashtable with the given name and set of values
|
boolean |
animate()
Allows the animation to reduce "repaint" calls when it returns false.
|
protected Dimension |
calcPreferredSize()
Calculates the preferred size based on component content.
|
void |
clear()
Cleares the text from the TextField
|
protected void |
commitChange()
Commit the changes made to the text field as a complete edit operation.
|
static TextArea |
create()
Default factory method
|
static TextArea |
create(int columns)
Construct text field/area depending on whether native in place editing is supported
|
static TextArea |
create(String text)
Construct text field/area depending on whether native in place editing is supported
|
static TextArea |
create(String text,
int columns)
Construct text field/area depending on whether native in place editing is supported
|
protected Container |
createSymbolTable()
Creates a symbol table container used by the showSymbolDialog method.
|
protected void |
deinitialize()
Invoked to indicate that the component initialization is being reversed
since the component was detached from the container hierarchy.
|
void |
deleteChar()
Performs a backspace operation
|
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.
|
void |
fireDataChanged(int type,
int index)
Alert the TextField listeners the text has been changed on the TextField
|
void |
fireDoneEvent()
Fire the done event to done listener
|
protected char |
getCharPerKeyCode(int pressCount,
int keyCode,
boolean longClick)
Returns the character matching the given key code after the given amount
of user presses
|
int |
getCommitTimeout()
The amount of time in milliseconds it will take for a change to get committed into
the field.
|
int |
getCursorBlinkTimeOff()
The amount of time in milliseconds in which the cursor is invisible
|
int |
getCursorBlinkTimeOn()
The amount of time in milliseconds in which the cursor is visible
|
int |
getCursorPosition()
Returns the position of the cursor char position
|
int |
getCursorX()
Returns the position of the cursor char position in the current line.
|
int |
getCursorY()
Returns the position of the cursor line position
|
static int |
getDefaultChangeInputModeKey()
Key to change the input mode on the device
|
static String[] |
getDefaultInputModeOrder()
Returns the order in which input modes are toggled by default
|
static int |
getDefaultSymbolDialogKey()
The default key for poping open the symbol dialog
|
ActionListener |
getDoneListener()
Gets the done listener of this TextField.
|
String |
getInputMode()
Returns the currently selected input mode
|
String[] |
getInputModeOrder()
Returns the order in which input modes are toggled
|
protected int |
getLongClickDuration()
The amount of time considered as a "long click" causing the long click method
to be invoked.
|
protected String |
getLongClickInputMode()
Returns the input mode for the ong click mode
|
static char[] |
getSymbolTable()
Returns the symbol table for the device
|
void |
insertChars(String c)
This method is responsible for adding a character into the field and is
the focal point for all input.
|
protected Command |
installCommands(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 commands
|
protected boolean |
isChangeInputMode(int keyCode)
Indicates whether the key changes the current input mode
|
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
|
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.
|
protected boolean |
isEditingEndTrigger(int keyCode)
Indicates whether the given key code should be ignored or should trigger
cause editing to end.
|
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.
|
boolean |
isEnableInputScroll()
Indicates whether text field input should scroll to the right side when no
more room for the input is present.
|
protected boolean |
isImmediateInputMode(String mode)
Returns true if the given input mode should commit immediately or
wait for the commit timeout
|
boolean |
isLeftAndRightEditingTrigger()
Indicates whether the left/right keys will trigger editing, this is true by default.
|
boolean |
isOverwriteMode()
Indicates that this is the overwrite mode
|
boolean |
isPendingCommit()
Returns true if the text field is waiting for a commit on editing
|
static boolean |
isQwertyAutoDetect()
Indicates whether the text field should try to auto detect qwerty and
switch the qwerty device flag implicitly
|
static boolean |
isQwertyDevice()
The default value for the qwerty flag so it doesn't need setting for every
text field individually.
|
boolean |
isQwertyInput()
True is this is a qwerty device or a device that is currently in
qwerty mode.
|
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
|
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
|
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.
|
protected boolean |
isSymbolDialogKey(int keyCode)
Returns true if this keycode is the one mapping to the symbol dialog popup
|
static boolean |
isUseNativeTextInput()
Indicates that native text input should be used in text field when in place editing is supported by the platform
|
boolean |
isUseSoftkeys()
When set to true softkeys are used to enable delete functionality
|
void |
keyPressed(int keyCode)
If this Component is focused, the key pressed event
will call this method
|
void |
keyReleased(int keyCode)
If this Component is focused, the key released event
will call this method
|
void |
keyRepeated(int keyCode)
If this Component is focused, the key repeat event
will call this method.
|
protected void |
longKeyPress(int keyCode)
If this Component is focused this method is invoked when the user presses
and holds the key
|
void |
paint(Graphics g)
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.
|
void |
pointerReleased(int x,
int y)
If this Component is focused, the pointer released event
will call this method
|
protected void |
removeCommands(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 commands
|
void |
removeDataChangeListener(DataChangedListener d)
Removes the listener for data change events
|
void |
setAlignment(int align)
Sets the Alignment of the TextArea to one of: CENTER, LEFT, RIGHT
|
static void |
setClearText(String text)
Set the text that should appear on the clear softkey
|
void |
setCommitTimeout(int commitTimeout)
The amount of time in milliseconds it will take for a change to get committed into
the field.
|
void |
setCursorBlinkTimeOff(int time)
The amount of time in milliseconds in which the cursor is invisible
|
void |
setCursorBlinkTimeOn(int time)
The amount of time in milliseconds in which the cursor is visible
|
void |
setCursorPosition(int pos)
Sets the position of the cursor char position
|
static void |
setDefaultChangeInputModeKey(int k)
Key to change the input mode on the device
|
static void |
setDefaultInputModeOrder(String[] order)
Sets the order in which input modes are toggled by default and allows
disabling/hiding an input mode
|
static void |
setDefaultSymbolDialogKey(int d)
The default key for poping open the symbol dialog
|
void |
setDoneListener(ActionListener l)
Sets a Done listener on the TextField - notice this listener will be called
only on supported platforms that supports done action on the keyboard
|
void |
setEditable(boolean b)
Sets this text area to be editable or readonly
|
void |
setEnableInputScroll(boolean enableInputScroll)
Indicates whether text field input should scroll to the right side when no
more room for the input is present.
|
void |
setInputMode(String inputMode)
Sets the current selected input mode matching one of the existing input
modes
|
void |
setInputModeOrder(String[] order)
Sets the order in which input modes are toggled and allows disabling/hiding
an input mode
|
void |
setLeftAndRightEditingTrigger(boolean leftAndRightEditingTrigger)
Indicates whether the left/right keys will trigger editing, this is true by default.
|
void |
setOverwriteMode(boolean overwriteMode)
Indicates that this is the overwrite mode
|
static void |
setQwertyAutoDetect(boolean v)
Indicates whether the text field should try to auto detect qwerty and
switch the qwerty device flag implicitly
|
static void |
setQwertyDevice(boolean v)
The default value for the qwerty flag so it doesn't need setting for every
text field individually.
|
void |
setQwertyInput(boolean qwerty)
True is this is a qwerty device or a device that is currently in
qwerty mode.
|
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
|
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
|
static void |
setSymbolTable(char[] table)
Sets the symbol table to show when the user clicks the symbol table key
|
static void |
setT9Text(String text)
Set the text that should appear on the T9 softkey
|
void |
setText(String text)
Sets the text within this text area
|
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
|
void |
setUseSoftkeys(boolean useSoftkeys)
When set to true softkeys are used to enable delete functionality
|
protected void |
showSymbolDialog()
Invoked to show the symbol dialog, this method can be overriden by subclasses to
manipulate the symbol table
|
boolean |
validChar(String c)
Checks if the candidate input is valid for this TextField
|
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, getPropertyNames, getPropertyTypeNames, getPropertyTypes, getPropertyValue, 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, initComponent, 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, setPropertyValue, 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 TextField()
public TextField(int columns)
columns
- - the number of columnspublic TextField(String text)
text
- the text of the fieldpublic TextField(String text, int columns)
text
- the text of the fieldcolumns
- - the number of columnspublic static boolean isUseNativeTextInput()
public static void setUseNativeTextInput(boolean aUseNativeTextInput)
aUseNativeTextInput
- the useNativeTextInput to setpublic static void setClearText(String text)
text
- localized text for the clear softbuttonpublic static void setT9Text(String text)
text
- text for the T9 softbuttonpublic boolean isEnableInputScroll()
TextArea
isEnableInputScroll
in class TextArea
public void setEnableInputScroll(boolean enableInputScroll)
enableInputScroll
- true to enable scrolling to the sidepublic void deleteChar()
public static TextArea create(String text, int columns)
text
- the text of the fieldcolumns
- - the number of columnspublic static TextArea create()
public static TextArea create(int columns)
columns
- - the number of columnspublic static TextArea create(String text)
text
- the text of the fieldprotected void commitChange()
public boolean isPendingCommit()
TextArea
isPendingCommit
in class TextArea
public void setCommitTimeout(int commitTimeout)
commitTimeout
- indicates the amount of time that should elapse for a commit
to automatically occurpublic int getCommitTimeout()
public void setInputMode(String inputMode)
inputMode
- the display name of the input mode by default the following modes
are supported: Abc, ABC, abc, 123public String getInputMode()
TextArea
getInputMode
in class TextArea
protected boolean isChangeInputMode(int keyCode)
keyCode
- the codepublic static void addInputMode(String name, Hashtable values, boolean firstUpcase)
name
- a unique display name for the input mode e.g. ABC, 123 etc...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 keycodefirstUpcase
- indicates if this input mode in an input mode used for the special
case where the first letter is an upper case letterpublic String[] getInputModeOrder()
TextArea
getInputModeOrder
in class TextArea
public void setInputModeOrder(String[] order)
order
- the order for the input modes in this fieldpublic static String[] getDefaultInputModeOrder()
public static void setDefaultInputModeOrder(String[] order)
order
- the order for the input modes in all future created fieldsprotected String getLongClickInputMode()
protected char getCharPerKeyCode(int pressCount, int keyCode, boolean longClick)
pressCount
- number of times this keycode was pressedkeyCode
- the actual keycode input by the userlongClick
- does this click constitute a long clickpublic void setCursorPosition(int pos)
pos
- the cursor positionpublic int getCursorPosition()
TextArea
getCursorPosition
in class TextArea
public int getCursorY()
TextArea
getCursorY
in class TextArea
public int getCursorX()
TextArea
getCursorX
in class TextArea
public void setText(String text)
TextArea
public void clear()
protected boolean isClearKey(int keyCode)
keyCode
- the key code that might be the clear keyprotected void longKeyPress(int keyCode)
Component
longKeyPress
in class Component
keyCode
- the key code value to indicate a physical key.public boolean isQwertyInput()
TextArea
isQwertyInput
in class TextArea
public void setQwertyInput(boolean qwerty)
qwerty
- the value of qwerty modeprotected boolean isImmediateInputMode(String mode)
mode
- the input modepublic void insertChars(String c)
This method accepts a string for the more elaborate cases such as multi-char input and paste.
c
- character for insertionpublic boolean validChar(String c)
c
- the String to insertprotected void showSymbolDialog()
protected Container createSymbolTable()
public void keyReleased(int keyCode)
Component
keyReleased
in class TextArea
keyCode
- the key code value to indicate a physical key.protected int getLongClickDuration()
public static char[] getSymbolTable()
public static void setSymbolTable(char[] table)
table
- the symbol table of the device for the symbol table inputprotected boolean isCursorPositionCycle()
protected boolean isSymbolDialogKey(int keyCode)
keyCode
- the keycode to checkprotected void deinitialize()
Component
deinitialize
in class Component
public void setEditable(boolean b)
TextArea
setEditable
in class TextArea
b
- true is text are is editable; otherwise falsepublic void keyRepeated(int keyCode)
Component
keyRepeated
in class Component
keyCode
- the key code value to indicate a physical key.public void keyPressed(int keyCode)
Component
keyPressed
in class TextArea
keyCode
- the key code value to indicate a physical key.protected Command installCommands(Command clear, Command t9)
clear
- the clear commandt9
- the t9 commandprotected boolean isSelectableInteraction()
Component
isSelectableInteraction
in class TextArea
protected void fireClicked()
Component
fireClicked
in class TextArea
protected void removeCommands(Command clear, Command t9, Command originalClear)
clear
- the clear commandt9
- the t9 commandoriginalClear
- the command originally assigned as the clear command (or null if no command was assigned before)protected boolean isEditingTrigger(int keyCode)
keyCode
- the keycode passed to the keyPressed methodprotected boolean isEditingEndTrigger(int keyCode)
keyCode
- the keycode passed to the keyPressed methodpublic void paint(Graphics g)
Component
protected Dimension calcPreferredSize()
Component
calcPreferredSize
in class TextArea
public void setCursorBlinkTimeOn(int time)
time
- for the cursor to stay "on"public void setCursorBlinkTimeOff(int time)
time
- for the cursor to stay "off"public int getCursorBlinkTimeOn()
public int getCursorBlinkTimeOff()
public boolean animate()
Animation
Display
class.public void pointerReleased(int x, int y)
Component
pointerReleased
in class TextArea
x
- the pointer x coordinatey
- the pointer y coordinatepublic boolean isUseSoftkeys()
public void setUseSoftkeys(boolean useSoftkeys)
useSoftkeys
- true if softkeys should be usedpublic void setDoneListener(ActionListener l)
l
- the listenerpublic ActionListener getDoneListener()
public void fireDoneEvent()
public void addDataChangeListener(DataChangedListener d)
d
- the listenerpublic void removeDataChangeListener(DataChangedListener d)
d
- the listenerpublic void fireDataChanged(int type, int index)
type
- the event type: Added, Removed or Changeindex
- cursor location of the eventpublic boolean isReplaceMenu()
public void setReplaceMenu(boolean replaceMenu)
replaceMenu
- true if the menu should be replacedpublic static boolean isReplaceMenuDefault()
public static void setReplaceMenuDefault(boolean replaceMenu)
replaceMenu
- true if the menu should be replacedpublic static void setQwertyAutoDetect(boolean v)
v
- true for qwerty auto detectionpublic static void setQwertyDevice(boolean v)
v
- true for qwerty devicepublic static boolean isQwertyAutoDetect()
public static boolean isQwertyDevice()
public static void setDefaultChangeInputModeKey(int k)
k
- key to change the input modepublic static int getDefaultChangeInputModeKey()
public static void setDefaultSymbolDialogKey(int d)
d
- new key valuepublic static int getDefaultSymbolDialogKey()
public void setOverwriteMode(boolean overwriteMode)
overwriteMode
- set to true if input with overwrite characterspublic boolean isOverwriteMode()
public void setLeftAndRightEditingTrigger(boolean leftAndRightEditingTrigger)
leftAndRightEditingTrigger
- Indicates whether the left/right keys will trigger editingpublic boolean isLeftAndRightEditingTrigger()
public void setAlignment(int align)
TextArea
setAlignment
in class TextArea
align
- alignment valueComponent.CENTER
,
Component.LEFT
,
Component.RIGHT