jMobileCore toolkit

com.jmobilecore.ui.core
Class TextArea

java.lang.Object
  extended by com.jmobilecore.ui.core.Component
      extended by com.jmobilecore.ui.core.TextComponent
          extended by com.jmobilecore.ui.core.TextArea

public class TextArea
extends TextComponent

A textArea object is a text component that allows for the editing of a single line of text.

Author:
Evgeniy Krapiva, Greg Gridin

Field Summary
 TextAreaComposer composer
          Handles input of the number keys
 int rows
          The number of rows in the TextArea.
static int ROWS
          Default height of component
static byte SYMBOL_WRAPPING
          By symbol wrapping style
static byte WORD_WRAPPING
          By words wrapping style
 
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
TextArea()
          Constructs a new text area with the empty string as text.
TextArea(int nRows)
          Constructs a new text area with the specified number of rows and the empty string as text.
TextArea(int nRows, int constr)
          Constructs a new text area with the specified number of rows, the binary mask of constraints and the empty string as text.
TextArea(java.lang.String text)
          Constructs a new text area with the specified text.
TextArea(java.lang.String text, int nRows)
          Constructs a new text area with the specified text, and with the specified number of rows
TextArea(java.lang.String text, int nRows, int constr)
          Constructs a new text area with the specified text, the specified number of rows and binary mask constraints
 
Method Summary
 void append(java.lang.String str)
          Appends the given text to the text area's current text.
protected  AbstractComposer getComposer()
          Gets current input composer
 java.lang.String getText()
          Returns the text that is presented by this text component.
 void insert(java.lang.String str, int pos)
          Inserts the specified text at the specified position in this text area.
 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)
          Paints the cursor for this component
 void setFont(javax.microedition.lcdui.Font font)
          Sets the font of 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.
 void setWrappingStyle(byte style)
          Sets the component wrapping style
 
Methods inherited from class com.jmobilecore.ui.core.TextComponent
addValidChars, destructor, 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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

composer

public TextAreaComposer composer
Handles input of the number keys


rows

public int rows
The number of rows in the TextArea. This parameter will determine the text area's height.


ROWS

public static final int ROWS
Default height of component

See Also:
Constant Field Values

SYMBOL_WRAPPING

public static final byte SYMBOL_WRAPPING
By symbol wrapping style

See Also:
Constant Field Values

WORD_WRAPPING

public static final byte WORD_WRAPPING
By words wrapping style

See Also:
Constant Field Values
Constructor Detail

TextArea

public TextArea()
Constructs a new text area with the empty string as text.


TextArea

public TextArea(int nRows)
Constructs a new text area with the specified number of rows and the empty string as text.

Parameters:
nRows - the number of rows

TextArea

public TextArea(int nRows,
                int constr)
Constructs a new text area with the specified number of rows, the binary mask of constraints and the empty string as text.

Parameters:
nRows - the number of rows
constr - constraints binary mask

TextArea

public TextArea(java.lang.String text)
Constructs a new text area with the specified text.

Parameters:
text - the text to be displayed; if text is null, the empty string "" will be displayed

TextArea

public TextArea(java.lang.String text,
                int nRows)
Constructs a new text area with the specified text, and with the specified number of rows

Parameters:
text - the text to be displayed; if text is null, the empty string "" will be displayed
nRows - the number of rows

TextArea

public TextArea(java.lang.String text,
                int nRows,
                int constr)
Constructs a new text area with the specified text, the specified number of rows and binary mask constraints

Parameters:
text - the text to be displayed; if text is null, the empty string "" will be displayed
nRows - the number of rows
constr - constraints binary mask
Method Detail

append

public void append(java.lang.String str)
Appends the given text to the text area's current text.


getComposer

protected AbstractComposer getComposer()
Gets current input composer

Specified by:
getComposer in class TextComponent

getText

public java.lang.String getText()
Returns the text that is presented by this text component.


insert

public void insert(java.lang.String str,
                   int pos)
Inserts the specified text at the specified position in this text area.


keyPressed

public boolean keyPressed(int keyCode)
Responds to a key press.

If the key is a number key and the constraint is 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.

Overrides:
keyPressed in class Component
Parameters:
keyCode - The code for the key that was pressed.
Returns:
true if the key was successfully processed, false otherwise

paint

public void paint(javax.microedition.lcdui.Graphics g)
Paints the component

Overrides:
paint in class Component
Parameters:
g - Graphics object

paintCursor

protected void paintCursor(javax.microedition.lcdui.Graphics g)
Paints the cursor for this component

Parameters:
g - Graphics object

setFont

public void setFont(javax.microedition.lcdui.Font font)
Sets the font of this component.

Overrides:
setFont in class Component
Parameters:
font - the font to become this component's font; if this parameter is null then this component font won't be changed

setHeight

protected void setHeight()
Calculates the height of the component.

Overrides:
setHeight in class Component

setText

public void setText(java.lang.String newText)
Sets the text that is presented by this text component to be the specified text.

Parameters:
newText - the new text.

setWrappingStyle

public void setWrappingStyle(byte style)
Sets the component wrapping style

Parameters:
style - indicates new wrapping style
See Also:
WORD_WRAPPING, SYMBOL_WRAPPING

jMobileCore toolkit