|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.sun.lwuit.Component com.sun.lwuit.TextArea com.sun.lwuit.TextField
public class TextField
Allows in place editing using a lightweight API without necessarily moving to the external native text box. The main drawback in this approach is that editing can't support features such as T9 and might not have the same keymapping or behavior of the native text input.
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 declated in TextArea are ignored with the exception of PASSWORD.
Field Summary |
---|
Fields inherited from class com.sun.lwuit.TextArea |
---|
ANY, DECIMAL, EMAILADDR, INITIAL_CAPS_SENTENCE, INITIAL_CAPS_WORD, NON_PREDICTIVE, NUMERIC, PASSWORD, PHONENUMBER, SENSITIVE, UNEDITABLE, URL |
Fields inherited from class com.sun.lwuit.Component |
---|
BOTTOM, BRB_CENTER_OFFSET, BRB_CONSTANT_ASCENT, BRB_CONSTANT_DESCENT, BRB_OTHER, CENTER, LEFT, RIGHT, TOP |
Constructor Summary | |
---|---|
TextField()
Default constructor |
|
TextField(int columns)
Construct a text field with space reserved for columns |
|
TextField(java.lang.String text)
Construct text field |
|
TextField(java.lang.String text,
int columns)
Construct text field |
Method Summary | |
---|---|
void |
addDataChangeListener(DataChangedListener d)
Adds a listener for data change events it will be invoked for every change made to the text field |
static void |
addInputMode(java.lang.String name,
java.util.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(java.lang.String text)
Construct text field/area depending on whether native in place editing is supported |
static TextArea |
create(java.lang.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. |
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 java.lang.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 |
java.lang.String |
getInputMode()
Returns the currently selected input mode |
java.lang.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 java.lang.String |
getLongClickInputMode()
Returns the input mode for the ong click mode |
static char[] |
getSymbolTable()
Returns the symbol table for the device |
void |
insertChars(java.lang.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(java.lang.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(java.lang.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(java.lang.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 |
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(java.lang.String inputMode)
Sets the current selected input mode matching one of the existing input modes |
void |
setInputModeOrder(java.lang.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(java.lang.String text)
Set the text that should appear on the T9 softkey |
void |
setText(java.lang.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(java.lang.String c)
Checks if the candidate input is valid for this TextField |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public TextField()
public TextField(int columns)
columns
- - the number of columnspublic TextField(java.lang.String text)
text
- the text of the fieldpublic TextField(java.lang.String text, int columns)
text
- the text of the fieldcolumns
- - the number of columnsMethod Detail |
---|
public static boolean isUseNativeTextInput()
public static void setUseNativeTextInput(boolean aUseNativeTextInput)
aUseNativeTextInput
- the useNativeTextInput to setpublic static void setClearText(java.lang.String text)
text
- localized text for the clear softbuttonpublic static void setT9Text(java.lang.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(java.lang.String text, int columns)
text
- the text of the fieldcolumns
- - the number of columns
public static TextArea create()
public static TextArea create(int columns)
columns
- - the number of columns
public static TextArea create(java.lang.String text)
text
- the text of the field
protected 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(java.lang.String inputMode)
inputMode
- the display name of the input mode by default the following modes
are supported: Abc, ABC, abc, 123public java.lang.String getInputMode()
TextArea
getInputMode
in class TextArea
protected boolean isChangeInputMode(int keyCode)
keyCode
- the code
public static void addInputMode(java.lang.String name, java.util.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 java.lang.String[] getInputModeOrder()
TextArea
getInputModeOrder
in class TextArea
public void setInputModeOrder(java.lang.String[] order)
order
- the order for the input modes in this fieldpublic static java.lang.String[] getDefaultInputModeOrder()
public static void setDefaultInputModeOrder(java.lang.String[] order)
order
- the order for the input modes in all future created fieldsprotected java.lang.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 click
public 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(java.lang.String text)
TextArea
setText
in class TextArea
text
- new value for the text areapublic void clear()
protected boolean isClearKey(int keyCode)
keyCode
- the key code that might be the clear key
protected 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(java.lang.String mode)
mode
- the input mode
public void insertChars(java.lang.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(java.lang.String c)
c
- the String to insert
protected 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 check
protected 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 command
protected 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 method
protected boolean isEditingEndTrigger(int keyCode)
keyCode
- the keycode passed to the keyPressed method
public void paint(Graphics g)
Component
paint
in interface Animation
paint
in class TextArea
g
- the component graphicsprotected 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.
animate
in interface Animation
animate
in class Component
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 addDataChangeListener(DataChangedListener d)
d
- the listenerpublic void removeDataChangeListener(DataChangedListener d)
d
- the listenerpublic 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
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |