|
jMobileCore toolkit | |||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.jmobilecore.ui.core.Component
com.jmobilecore.ui.core.TextComponent
com.jmobilecore.ui.core.TextField
public class TextField
A TextField
object is a text component
that allows for the editing of a single line of text.
Field Summary | |
---|---|
int |
adjustment
|
protected int |
calculatedCaretPosition
|
protected int |
calculatedCursorOffset
|
protected AbstractComposer |
composer
Handles input of the phone keys |
protected int |
currentLength
|
static int |
DEFAULT_SIZE
Default text size |
char |
echoChar
The echo character, which is used when the user wishes to disguise the characters typed into the text field. |
protected static int |
HOFFSET
The total horizontal gap for textfield text |
protected static boolean |
SCROLLABLE
|
protected static int |
VOFFSET
The total vertical gap for textfield text |
Fields inherited from class com.jmobilecore.ui.core.TextComponent |
---|
ALL_SPEC_CHARS, BORDER_GAP, BORDER_WIDTH, C_ALL_SPEC_CHARS, C_ALPHA, C_ALPHA_NUMERIC, C_ANY, C_EMAIL, C_EMAIL_SPEC_CHARS, C_LOWER_CASE, C_NO_CHARS, C_NUMERIC, C_SPACE, C_UPPER_CASE, cHandler, CHAR_OPTIONS, charOptionCounter, constraint, CURSOR_DELAY, CURSOR_TYPE_LINE, CURSOR_TYPE_SYMBOL, editable, EMAIL_SPEC_CHARS, insertMode, KEY_OPTIONS, lastKeyCode, LC_CHARS, NUMERIC_CHARS, SPACE_CHARS, UC_CHARS, validChars |
Fields inherited from class com.jmobilecore.ui.core.Component |
---|
alignment, background, CENTER, focusable, focusedBackground, focusedForeground, font, foreground, height, isCompletelyVisible, isFocused, isVisible, LEFT, parentScreen, RIGHT, screenY, valid, width |
Constructor Summary | |
---|---|
TextField()
Constructs a new text field. |
|
TextField(int maxTextLen)
Constructs a new text field with the specified length. |
|
TextField(int maxTextLen,
int constr)
Constructs a new text field with the specified length and constraints. |
Method Summary | |
---|---|
protected void |
adjust(char[] text,
int caretPosition,
int cursorOffset)
Adjusts the cursor position |
void |
destructor()
Default destructor. |
protected AbstractComposer |
getComposer()
Gets current input composer |
int |
getCursorOffset(char[] text,
int caretPosition)
Returns the cursor offset (in pixels) for the composed string |
protected char[] |
getFormattedText(boolean calcCursorOffset)
|
java.lang.String |
getText()
Returns the text that is presented by this text component. |
protected void |
init(int maxTextLen)
|
boolean |
keyPressed(int keyCode)
Responds to a key press. |
void |
paint(javax.microedition.lcdui.Graphics g)
Paints the component |
protected void |
paintCursor(javax.microedition.lcdui.Graphics g,
char[] text,
int caretPosition,
int cursorOffset,
byte cursorType)
Paints the cursor for this component |
protected void |
setHeight()
Calculates the height of the component. |
void |
setText(java.lang.String newText)
Sets the text that is presented by this text component to be the specified text. |
Methods inherited from class com.jmobilecore.ui.core.TextComponent |
---|
addValidChars, getCaretPosition, getKeyOption, initCursor, isCharValid, preProcessKeyCode, processKeyCode, resetCursor, resetCursorHandler, setCaretPosition |
Methods inherited from class com.jmobilecore.ui.core.Component |
---|
getBackground, getFont, getForeground, getHeight, getWidth, invalidate, isFocusOwner, keyReleased, keyRepeated, paintBackground, pointerDragged, pointerPressed, pointerReleased, prepareForeground, releaseFocus, requestFocus, setFont |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public int adjustment
protected int calculatedCaretPosition
protected int calculatedCursorOffset
protected AbstractComposer composer
protected int currentLength
public static final int DEFAULT_SIZE
public char echoChar
0
.
protected static final int HOFFSET
protected static final boolean SCROLLABLE
protected static final int VOFFSET
Constructor Detail |
---|
public TextField()
public TextField(int maxTextLen)
maxTextLen
- the maximum text lengthpublic TextField(int maxTextLen, int constr)
maxTextLen
- the maximum text lengthconstr
- constraints binary maskTextComponent
Method Detail |
---|
protected void adjust(char[] text, int caretPosition, int cursorOffset)
public void destructor()
TextComponent
destructor
in class TextComponent
protected AbstractComposer getComposer()
getComposer
in class TextComponent
public int getCursorOffset(char[] text, int caretPosition)
protected char[] getFormattedText(boolean calcCursorOffset)
public java.lang.String getText()
protected void init(int maxTextLen)
public boolean keyPressed(int keyCode)
TextComponent.C_NUMERIC
only,
no timing interval is used, the number is immediately inserted into the
field (if there is room).
If the key is a number key and the constraint IS NOT ONLY TextComponent.C_NUMERIC
,
the timing interval begins so that
characters may be cycled through via repeated presses of the same key
within the timing interval.
Presses of the left and right sides of the 4-way navigation key move the
cursor one character left or right within the field. Pressing the *
key deletes the character to the left of the cursor. Pressing the #
key inserts a space at the cursor position.
You can override this method if you want a custom component to perform
additional filtering of key presses. For example, if you want a field that
accepts only odd digits you could extend this class, ensure it is
TextComponent.C_NUMERIC
, then in this method check that the pressed key is an odd
digit before passing it to the parent's keyPressed
method.
keyPressed
in class Component
keyCode
- The code for the key that was pressed.
true
if the key was successfully processed, false
otherwisepublic void paint(javax.microedition.lcdui.Graphics g)
paint
in class Component
g
- Graphics objectprotected void paintCursor(javax.microedition.lcdui.Graphics g, char[] text, int caretPosition, int cursorOffset, byte cursorType)
g
- Graphics objectprotected void setHeight()
setHeight
in class Component
public void setText(java.lang.String newText)
newText
- the new text.
|
jMobileCore toolkit | |||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |