de.enough.polish.ui
Class FakeTextFieldCustomItem

java.lang.Object
  extended by javax.microedition.lcdui.Item
      extended by javax.microedition.lcdui.CustomItem
          extended by de.enough.polish.ui.FakeCustomItem
              extended by de.enough.polish.ui.FakeStringCustomItem
                  extended by de.enough.polish.ui.FakeTextFieldCustomItem
All Implemented Interfaces:
CommandListener, ItemCommandListener

public class FakeTextFieldCustomItem
extends FakeStringCustomItem
implements CommandListener, ItemCommandListener

A TextField is an editable text component that may be placed into a Form. It can be given a piece of text that is used as the initial value.

A TextField has a maximum size, which is the maximum number of characters that can be stored in the object at any time (its capacity). This limit is enforced when the TextField instance is constructed, when the user is editing text within the TextField, as well as when the application program calls methods on the TextField that modify its contents. The maximum size is the maximum stored capacity and is unrelated to the number of characters that may be displayed at any given time. The number of characters displayed and their arrangement into rows and columns are determined by the device.

The implementation may place a boundary on the maximum size, and the maximum size actually assigned may be smaller than the application had requested. The value actually assigned will be reflected in the value returned by getMaxSize(). A defensively-written application should compare this value to the maximum size requested and be prepared to handle cases where they differ.

Input Constraints

The TextField shares the concept of input constraints with the TextBox class. The different constraints allow the application to request that the user's input be restricted in a variety of ways. The implementation is required to restrict the user's input as requested by the application. For example, if the application requests the NUMERIC constraint on a TextField, the implementation must allow only numeric characters to be entered.

The actual contents of the text object are set and modified by and are reported to the application through the TextBox and TextField APIs. The displayed contents may differ from the actual contents if the implementation has chosen to provide special formatting suitable for the text object's constraint setting. For example, a PHONENUMBER field might be displayed with digit separators and punctuation as appropriate for the phone number conventions in use, grouping the digits into country code, area code, prefix, etc. Any spaces or punctuation provided are not considered part of the text object's actual contents. For example, a text object with the PHONENUMBER constraint might display as follows:


 (408) 555-1212    
 

but the actual contents of the object visible to the application through the APIs would be the string "4085551212". The size method reflects the number of characters in the actual contents, not the number of characters that are displayed, so for this example the size method would return 10.

Some constraints, such as DECIMAL, require the implementation to perform syntactic validation of the contents of the text object. The syntax checking is performed on the actual contents of the text object, which may differ from the displayed contents as described above. Syntax checking is performed on the initial contents passed to the constructors, and it is also enforced for all method calls that affect the contents of the text object. The methods and constructors throw IllegalArgumentException if they would result in the contents of the text object not conforming to the required syntax.

The value passed to the setConstraints() method consists of a restrictive constraint setting described above, as well as a variety of flag bits that modify the behavior of text entry and display. The value of the restrictive constraint setting is in the low order 16 bits of the value, and it may be extracted by combining the constraint value with the CONSTRAINT_MASK constant using the bit-wise AND (&) operator. The restrictive constraint settings are as follows:

ANY
EMAILADDR
NUMERIC
PHONENUMBER
URL
DECIMAL

The modifier flags reside in the high order 16 bits of the constraint value, that is, those in the complement of the CONSTRAINT_MASK constant. The modifier flags may be tested individually by combining the constraint value with a modifier flag using the bit-wise AND (&) operator. The modifier flags are as follows:

PASSWORD
UNEDITABLE
SENSITIVE
NON_PREDICTIVE
INITIAL_CAPS_WORD
INITIAL_CAPS_SENTENCE

Input Modes

The TextField shares the concept of input modes with the TextBox class. The application can request that the implementation use a particular input mode when the user initiates editing of a TextField or TextBox. The input mode is a concept that exists within the user interface for text entry on a particular device. The application does not request an input mode directly, since the user interface for text entry is not standardized across devices. Instead, the application can request that the entry of certain characters be made convenient. It can do this by passing the name of a Unicode character subset to the setInitialInputMode() method. Calling this method requests that the implementation set the mode of the text entry user interface so that it is convenient for the user to enter characters in this subset. The application can also request that the input mode have certain behavioral characteristics by setting modifier flags in the constraints value.

The requested input mode should be used whenever the user initiates the editing of a TextBox or TextField object. If the user had changed input modes in a previous editing session, the application's requested input mode should take precedence over the previous input mode set by the user. However, the input mode is not restrictive, and the user is allowed to change the input mode at any time during editing. If editing is already in progress, calls to the setInitialInputMode method do not affect the current input mode, but instead take effect at the next time the user initiates editing of this text object.

The initial input mode is a hint to the implementation. If the implementation cannot provide an input mode that satisfies the application's request, it should use a default input mode.

The input mode that results from the application's request is not a restriction on the set of characters the user is allowed to enter. The user MUST be allowed to switch input modes to enter any character that is allowed within the current constraint setting. The constraint setting takes precedence over an input mode request, and the implementation may refuse to supply a particular input mode if it is inconsistent with the current constraint setting.

For example, if the current constraint is ANY, the call


 setInitialInputMode("MIDP_UPPERCASE_LATIN");    

should set the initial input mode to allow entry of uppercase Latin characters. This does not restrict input to these characters, and the user will be able to enter other characters by switching the input mode to allow entry of numerals or lowercase Latin letters. However, if the current constraint is NUMERIC, the implementation may ignore the request to set an initial input mode allowing MIDP_UPPERCASE_LATIN characters because these characters are not allowed in a TextField whose constraint is NUMERIC. In this case, the implementation may instead use an input mode that allows entry of numerals, since such an input mode is most appropriate for entry of data under the NUMERIC constraint.

A string is used to name the Unicode character subset passed as a parameter to the setInitialInputMode() method. String comparison is case sensitive.

Unicode character blocks can be named by adding the prefix "UCB_" to the the string names of fields representing Unicode character blocks as defined in the J2SE class java.lang.Character.UnicodeBlock. Any Unicode character block may be named in this fashion. For convenience, the most common Unicode character blocks are listed below.

UCB_BASIC_LATIN
UCB_GREEK
UCB_CYRILLIC
UCB_ARMENIAN
UCB_HEBREW
UCB_ARABIC
UCB_DEVANAGARI
UCB_BENGALI
UCB_THAI
UCB_HIRAGANA
UCB_KATAKANA
UCB_HANGUL_SYLLABLES

"Input subsets" as defined by the J2SE class java.awt.im.InputSubset may be named by adding the prefix "IS_" to the string names of fields representing input subsets as defined in that class. Any defined input subset may be used. For convenience, the names of the currently defined input subsets are listed below.

IS_FULLWIDTH_DIGITS
IS_FULLWIDTH_LATIN
IS_HALFWIDTH_KATAKANA
IS_HANJA
IS_KANJI
IS_LATIN
IS_LATIN_DIGITS
IS_SIMPLIFIED_HANZI
IS_TRADITIONAL_HANZI

MIDP has also defined the following character subsets:

MIDP_UPPERCASE_LATIN - the subset of IS_LATIN that corresponds to uppercase Latin letters
MIDP_LOWERCASE_LATIN - the subset of IS_LATIN that corresponds to lowercase Latin letters

Finally, implementation-specific character subsets may be named with strings that have a prefix of "X_". In order to avoid namespace conflicts, it is recommended that implementation-specific names include the name of the defining company or organization after the initial "X_" prefix.

For example, a Japanese language application might have a particular TextField that the application intends to be used primarily for input of words that are "loaned" from languages other than Japanese. The application might request an input mode facilitating Hiragana input by issuing the following method call:


 textfield.setInitialInputMode("UCB_HIRAGANA");       

Implementation Note

Implementations need not compile in all the strings listed above. Instead, they need only to compile in the strings that name Unicode character subsets that they support. If the subset name passed by the application does not match a known subset name, the request should simply be ignored without error, and a default input mode should be used. This lets implementations support this feature reasonably inexpensively. However, it has the consequence that the application cannot tell whether its request has been accepted, nor whether the Unicode character subset it has requested is actually a valid subset.


Since:
MIDP 1.0
Author:
Robert Virkus, robert@enough.de, Andrew Barnes, andy@geni.com.au basic implementation of direct input

Field Summary
static int ANY
          The user is allowed to enter any text.
protected  char caretChar
           
static String[] CHARACTERS
          map of characters that can be triggered witht the 0..9 and #, * keys
static String[] CHARACTERS_UPPER
           
protected static String charactersKey0
           
protected static String charactersKeyPound
           
protected static String charactersKeyStar
           
static Command CLEAR_CMD
          Command for clearing the complete text of this field
static int CONSTRAINT_MASK
          The mask value for determining the constraint mode.
static int DECIMAL
          The user is allowed to enter numeric values with optional decimal fractions, for example "-123", "0.123", or ".5".
protected static String[] definedSymbols
           
static Command DELETE_CMD
           
static int EMAILADDR
          The user is allowed to enter an e-mail address.
protected  char emailSeparatorChar
           
static Command ENTER_SYMBOL_CMD
           
static int FIXED_POINT_DECIMAL
          The user is allowed to enter numeric values with two decimal fractions, for example "-123.00", "0.13", or "0.50".
protected  boolean flashCaret
           
protected  StringItem infoItem
           
static int INITIAL_CAPS_NEVER
          A flag to hint to the implementation that during text editing,the initial letter of each sentence should NOT be capitalized.
static int INITIAL_CAPS_SENTENCE
          This flag is a hint to the implementation that during text editing, the initial letter of each sentence should be capitalized.
static int INITIAL_CAPS_WORD
          This flag is a hint to the implementation that during text editing, the initial letter of each word should be capitalized.
protected  int inputMode
           
protected  boolean isUneditable
           
static int KEY_CHANGE_MODE
           
static int KEY_DELETE
           
protected  Object lock
           
static int MODE_FIRST_UPPERCASE
          input mode for entering one uppercase followed by lowercase characters
static int MODE_LOWERCASE
          input mode for lowercase characters
static int MODE_NATIVE
          input mode for input using a separete native TextBox
static int MODE_NUMBERS
          input mode for numeric characters
static int MODE_UPPERCASE
          input mode for uppercase characters
static int NON_PREDICTIVE
          Indicates that the text entered does not consist of words that are likely to be found in dictionaries typically used by predictive input schemes.
static int NUMERIC
          The user is allowed to enter only an integer value.
static int PASSWORD
          Indicates that the text entered is confidential data that should be obscured whenever possible.
static int PHONENUMBER
          The user is allowed to enter a phone number.
static int SENSITIVE
          Indicates that the text entered is sensitive data that the implementation must never store into a dictionary or table for use in predictive, auto-completing, or other accelerated input schemes.
protected  boolean showCaret
           
protected static List symbolsList
           
protected  String title
           
static int UNEDITABLE
          Indicates that editing is currently disallowed.
static int URL
          The user is allowed to enter a URL.
static boolean usesDynamicCharset
           
 
Fields inherited from class de.enough.polish.ui.FakeStringCustomItem
animateTextWrap, availableTextWidth, clipText, font, isHorizontalAnimationDirectionRight, isTextInitializationRequired, maxLines, maxLinesAppendix, maxLinesAppendixPosition, text, textColor, textEffect, textHorizontalAdjustment, textLayout, textLines, textVerticalAdjustment, textWidth, textWrapDirection, textWrapSpeed, useSingleLine, xOffset
 
Fields inherited from class de.enough.polish.ui.FakeCustomItem
_bbField, appearanceMode, availableHeight, availableWidth, availContentHeight, availContentWidth, background, backgroundHeight, backgroundWidth, backgroundYOffset, beforeWidth, bgBorder, border, BUTTON, cacheItemImage, colSpan, commands, completeBackground, completeBackgroundPadding, completeBorder, contentHeight, contentWidth, contentX, contentXAdjustment, contentY, contentYAdjustment, cssHeight, cssSelector, cssWidth, defaultCommand, focusedStyle, HORIZONTAL, HYPERLINK, ignoreRepaintRequests, includeLabel, INTERACTIVE, internalHeight, internalWidth, internalX, internalY, isContentVisible, isFocused, isInlineLabel, isInvisible, isLayoutCenter, isLayoutExpand, isLayoutRight, isPressed, isShown, isStyleInitialised, itemCommandListener, itemHeight, itemWidth, label, labelStyle, landscapeStyle, layout, LAYOUT_2, LAYOUT_BOTTOM, LAYOUT_CENTER, LAYOUT_DEFAULT, LAYOUT_EXPAND, LAYOUT_LEFT, LAYOUT_NEWLINE_AFTER, LAYOUT_NEWLINE_BEFORE, LAYOUT_RIGHT, LAYOUT_SHRINK, LAYOUT_TOP, LAYOUT_VCENTER, LAYOUT_VEXPAND, LAYOUT_VSHRINK, marginBottom, marginLeft, marginRight, marginTop, maximumHeight, maximumItemHeight, maximumItemWidth, maximumWidth, minimumHeight, minimumItemHeight, minimumItemWidth, minimumWidth, nativeItem, NO_POSITION_SET, opacity, opacityPaintNormally, opacityRgbData, paddingBottom, paddingHorizontal, paddingLeft, paddingRight, paddingTop, paddingVertical, parent, PLAIN, portraitStyle, preferredHeight, preferredWidth, preserveViewType, relativeX, relativeY, rowSpan, screen, setView, style, TRANSPARENT, useSingleRow, VERTICAL, view, xAdjustment, yAdjustment
 
Fields inherited from class javax.microedition.lcdui.CustomItem
KEY_PRESS, KEY_RELEASE, KEY_REPEAT, NONE, POINTER_DRAG, POINTER_PRESS, POINTER_RELEASE, TRAVERSE_HORIZONTAL, TRAVERSE_VERTICAL
 
Constructor Summary
FakeTextFieldCustomItem(String label, String text, int maxSize, int constraints)
          Creates a new TextField object with the given label, initial contents, maximum size in characters, and constraints.
FakeTextFieldCustomItem(String label, String text, int maxSize, int constraints, Style style)
          Creates a new TextField object with the given label, initial contents, maximum size in characters, and constraints.
 
Method Summary
 void activate(boolean editable)
          Sets a blackberry field to selectable.
 boolean animate()
          Animates this item.
 void animate(long currentTime, ClippingRegion repaintRegion)
          Animates this item.
 void commandAction(Command cmd, Displayable box)
          Indicates that a command event has occurred on Displayable d.
 void commandAction(Command cmd, Item item)
          Called by the system to indicate that a command has been invoked on a particular item.
protected  void commitCurrentCharacter()
           
protected  String convertToFixedPointDecimal(String original)
          Converts the given entry into cash format.
protected  String createCssSelector()
          Retrieves the CSS selector for this item.
protected  void defocus(Style originalStyle)
          Removes the focus from this item.
 void delete(int offset, int length)
          Deletes characters from the TextField.
 void fieldChanged(net.rim.device.api.ui.Field field, int context)
          Notifies the TextField about changes in its native BlackBerry component.
protected  Style focus(Style focStyle, int direction)
          Focuses this item.
 int getCaretPosition()
          Gets the current input position.
 int getChars(char[] data)
          Copies the contents of the TextField into a character array starting at index zero.
 int getConstraints()
          Gets the current input constraints of the TextField.
static String[] getDefinedSymbols()
          Returns the defined symbols as a String array
 String getDotSeparatedDecimalString()
          Retrieves the decimal value entered with a dot as the decimal mark.
 StringItem getInfoItem()
          Returns the StringItem which is displaying the input info
 int getInputMode()
          Returns the current input mode.
 ItemCommandListener getItemCommandListener()
          Gets the listener for Commands to this Item.
 int getMaxSize()
          Returns the maximum size (number of characters) that can be stored in this TextField.
 int getNumberOfDecimalFractions()
          Retrieves the number of decimal fractions that are allowed for FIXED_POINT_DECIMAL constrained TextFields
 PredictiveAccess getPredictiveAccess()
           
 ArrayList getPredictiveMatchingWords()
          Retrieves matching words for the specified textfield.
 String getString()
          Gets the contents of the TextField as a string value.
protected  boolean handleKeyClear(int keyCode, int gameAction)
           
protected  boolean handleKeyInsert(int keyCode, int gameAction)
          Tries to interpret a key pressed event for inserting a character into this TextField.
protected  boolean handleKeyMode(int keyCode, int gameAction)
           
protected  boolean handleKeyNavigation(int keyCode, int gameAction)
           
protected  boolean handleKeyPressed(int keyCode, int gameAction)
          Handles the key-pressed event.
protected  boolean handleKeyReleased(int keyCode, int gameAction)
          Handles the key-released event.
protected  boolean handleKeyRepeated(int keyCode, int gameAction)
          Handles the key-repeated event.
protected  boolean handlePointerDragged(int relX, int relY)
          Handles the dragging/movement of a pointer.
protected  boolean handlePointerPressed(int x, int y)
          Handles the event when a pointer has been pressed at the specified position.
protected  boolean handlePointerReleased(int x, int y)
          Handles the event when a pointer has been pressed at the specified position.
protected  void hideNotify()
          Called by the system to notify the item that it is now completely invisible, when it previously had been at least partially visible.
protected  void initContent(int firstLineWidth, int availWidth, int availHeight)
          Initialises this item.
static void initSymbolsList()
           
 void insert(char[] data, int offset, int length, int position)
          Inserts a subrange of an array of characters into the contents of the TextField.
 void insert(String src, int position)
          Inserts a string into the contents of the TextField.
protected  void insertCharacter(char insertChar, boolean append, boolean commit)
           
 boolean isCskOpensNativeEditor()
          Returns true if the flag to open the native editor on CenterSoftKey press is set to true
 boolean isEditable()
          Checks if this textfield is edtiable.
 boolean isNoNewLine()
          Checks if the textfield should accept the enter key as an input which results in a new line.
 boolean isSuppressCommands()
          Checks if commands are currently suppressed by this TextField.
protected  boolean isValidInput(char insertChar, int position, String myText)
           
static void loadCharacterSets(InputStream lowercaseStream, InputStream uppercaseStream)
          Reads the .properties files for lowercase and uppercase letters and maps the values of the predefined keys to the character maps.
static void loadCharacterSets(InputStream lowercaseStream, InputStream uppercaseStream, String encoding)
          Reads the .properties files for lowercase and uppercase letters and maps the values of the predefined keys to the character maps.
static void loadCharacterSets(String lowercaseUrl, String uppercaseUrl)
          Reads the .properties files for lowercase and uppercase letters and maps the values of the predefined keys to the character maps.
static void loadCharacterSets(String lowercaseUrl, String uppercaseUrl, String encoding)
          Reads the .properties files for lowercase and uppercase letters and maps the values of the predefined keys to the character maps.
 void paintContent(int x, int y, int leftBorder, int rightBorder, Graphics g)
          Paints the content of this item.
 void setCaretPosition(int position)
          Sets the caret position.
 void setChars(char[] data, int offset, int length)
          Sets the contents of the TextField from a character array, replacing the previous contents.
 void setConstraints(int constraints)
          Sets the input constraints of the TextField.
 void setCskOpensNativeEditor(boolean cskOpensNativeEditor)
          Sets the flag to open the native editor on CenterSoftKey press
 void setEditable(boolean editable)
           
 void setHelpStyle()
          Sets the help style for this TextField with the use of style preprocessing e.g.: //#style myStyle setHelpStyle();
 void setHelpStyle(Style style)
          Sets the style of the help text
 void setHelpText(String text)
          Sets a help text for this TextField.
 void setInfoItem(StringItem infoItem)
          Sets the StringItem which should display the input info
 void setInitialInputMode(String characterSubset)
          Sets a hint to the implementation as to the input mode that should be used when the user initiates editing of this TextField.
 void setInputMode(int inputMode)
          Sets the input mode for this TextField.
 void setItemCommandListener(ItemCommandListener l)
          Sets a listener for Commands to this Item, replacing any previous ItemCommandListener.
 int setMaxSize(int maxSize)
          Sets the maximum size (number of characters) that can be contained in this TextField.
 void setNoComplexInput(boolean noComplexInput)
          Set if the textfield should accept only simple input.
 void setNoNewLine(boolean noNewLine)
          Set if the textfield should accept the enter key as an input which results in a new line.
 void setNumberOfDecimalFractions(int number)
          Sets the number of decimal fractions that are allowed for FIXED_POINT_DECIMAL constrained TextFields
 void setPredictiveAccess(PredictiveAccess predictive)
           
 void setPredictiveDictionary(String[] words)
          Allows the given words for the specified textfield.
 void setPredictiveInfo(String info)
           
 void setPredictiveWordNotFoundAlert(Alert alert)
          Set the word-not-found box in the textfield
 void setShowInputInfo(boolean show)
          (De)activates the input info element for this TextField.
 void setString(String text)
          Sets the contents of the TextField as a string value, replacing the previous contents.
 void setStyle(Style style)
          Sets the style of this item.
 void setStyle(Style style, boolean resetStyle)
          Sets the style of this item for animatable CSS attributes.
 void setSuppressCommands(boolean suppressCommands)
          Toggles the surpressing of commands for this TextField This has no effect when commands are globally suppressed by settting the preprocessing variable "polish.TextField.suppressCommands" to "true".
 void setTitle(String title)
          Sets the title to be displayed in the native textbox
protected  void showNotify()
          Called by the system to notify the item that it is now at least partially visible, when it previously had been completely invisible.
protected  void showTextBox()
          Shows the TextBox for entering texts.
 int size()
          Gets the number of characters that are currently stored in this TextField.
protected  void updateDeleteCommand(String newText)
           
 void updateInfo()
          Updates the information text
 void updateInternalArea()
          Updates the internal area on BB and similar platforms that contain native fields.
 
Methods inherited from class de.enough.polish.ui.FakeStringCustomItem
addRepaintArea, charWidth, drawString, getFont, getFontHeight, getLineHeight, getText, releaseResources, setContentWidth, setFont, setText, setText, setTextColor, setTextEffect, stringWidth, toString, wrap
 
Methods inherited from class de.enough.polish.ui.FakeCustomItem
addCommand, addCommand, addCommand, addCommands, addRelativeToBackgroundRegion, addRelativeToBackgroundRegion, addRelativeToContentRegion, containsCommand, destroy, fireEvent, getAbsoluteX, getAbsoluteY, getAppearanceMode, getAttribute, getAttributes, getAvailableContentHeight, getAvailableContentWidth, getAvailableHeight, getAvailableWidth, getBackgroundHeight, getBackgroundWidth, getBackgroundX, getBackgroundY, getBorderWidthBottom, getBorderWidthLeft, getBorderWidthRight, getBorderWidthTop, getContentHeight, getContentWidth, getContentX, getContentY, getDefaultCommand, getFocusedStyle, getInternalHeight, getInternalWidth, getInternalX, getInternalY, getItemAreaHeight, getItemAt, getItemCommands, getItemHeight, getItemHeight, getItemStateListener, getItemWidth, getItemWidth, getLabel, getLabelItem, getLayout, getMaximumHeight, getMaximumHeight, getMaximumWidth, getMaximumWidth, getMinContentHeight, getMinContentWidth, getMinimumHeight, getMinimumHeight, getMinimumWidth, getMinimumWidth, getNativeItem, getParent, getPrefContentHeight, getPrefContentWidth, getpreferredHeight, getpreferredWidth, getRgbData, getRgbData, getScreen, getStyle, getUiEventListener, getView, getView, handleCommand, handleCommand, handleGesture, handleGestureHold, handleGestureSwipeLeft, handleGestureSwipeRight, handlePointerDragged, handlePointerTouchDown, handlePointerTouchUp, init, initLayout, initMargin, initPadding, initStyle, isFocused, isInContentArea, isInContentWithPaddingArea, isInItemArea, isInItemArea, isInitialized, isInteractive, isLayoutBottom, isLayoutCenter, isLayoutExpand, isLayoutLeft, isLayoutNewlineAfter, isLayoutNewlineBefore, isLayoutRight, isLayoutShrink, isLayoutTop, isLayoutVerticalCenter, isLayoutVerticalExpand, isLayoutVerticalShrink, isPressed, isVisible, notifyItemPressedEnd, notifyItemPressedStart, notifyStateChanged, notifyUnvisited, notifyValueChanged, notifyVisited, onScreenSizeChanged, paint, paint, paintBackground, paintBackgroundAndBorder, paintBorder, paintCommands, paintFilter, removeAttribute, removeCommand, repaintFully, requestInit, setAbsoluteY, setAppearanceMode, setAttribute, setBackground, setBorder, setContentHeight, setDefaultCommand, setDefaultCommand, setInitialized, setItemCommandListener, setItemHeight, setItemStateListener, setItemTransition, setLabel, setLayout, setNativeItem, setParent, setParent, setpreferredSize, setStyle, setUiEventListener, setView, setVisible, show, showCommands, toImage, toRgbImage
 
Methods inherited from class javax.microedition.lcdui.CustomItem
getGameAction, getInteractionModes, invalidate, keyPressed, keyReleased, keyRepeated, pointerDragged, pointerPressed, pointerReleased, repaint, repaint, sizeChanged, traverse, traverseOut
 
Methods inherited from class javax.microedition.lcdui.Item
getPreferredHeight, getPreferredWidth, removeCommand, setPreferredSize
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ANY

public static final int ANY
The user is allowed to enter any text. Line breaks may be entered.

Constant 0 is assigned to ANY.

See Also:
Constant Field Values

EMAILADDR

public static final int EMAILADDR
The user is allowed to enter an e-mail address.

Constant 1 is assigned to EMAILADDR.

See Also:
Constant Field Values

NUMERIC

public static final int NUMERIC
The user is allowed to enter only an integer value. The implementation must restrict the contents either to be empty or to consist of an optional minus sign followed by a string of one or more decimal numerals. Unless the value is empty, it will be successfully parsable using Integer.parseInt(String).

The minus sign consumes space in the text object. It is thus impossible to enter negative numbers into a text object whose maximum size is 1.

Constant 2 is assigned to NUMERIC.

See Also:
Constant Field Values

PHONENUMBER

public static final int PHONENUMBER
The user is allowed to enter a phone number. The phone number is a special case, since a phone-based implementation may be linked to the native phone dialing application. The implementation may automatically start a phone dialer application that is initialized so that pressing a single key would be enough to make a call. The call must not made automatically without requiring user's confirmation. Implementations may also provide a feature to look up the phone number in the device's phone or address database.

The exact set of characters allowed is specific to the device and to the device's network and may include non-numeric characters, such as a "+" prefix character.

Some platforms may provide the capability to initiate voice calls using the MIDlet.platformRequest method.

Constant 3 is assigned to PHONENUMBER.

See Also:
Constant Field Values

URL

public static final int URL
The user is allowed to enter a URL.

Constant 4 is assigned to URL.

See Also:
Constant Field Values

DECIMAL

public static final int DECIMAL
The user is allowed to enter numeric values with optional decimal fractions, for example "-123", "0.123", or ".5".

The implementation may display a period "." or a comma "," for the decimal fraction separator, depending on the conventions in use on the device. Similarly, the implementation may display other device-specific characters as part of a decimal string, such as spaces or commas for digit separators. However, the only characters allowed in the actual contents of the text object are period ".", minus sign "-", and the decimal digits.

The actual contents of a DECIMAL text object may be empty. If the actual contents are not empty, they must conform to a subset of the syntax for a FloatingPointLiteral as defined by the Java Language Specification, section 3.10.2. This subset syntax is defined as follows: the actual contents must consist of an optional minus sign "-", followed by one or more whole-number decimal digits, followed by an optional fraction separator, followed by zero or more decimal fraction digits. The whole-number decimal digits may be omitted if the fraction separator and one or more decimal fraction digits are present.

The syntax defined above is also enforced whenever the application attempts to set or modify the contents of the text object by calling a constructor or a method.

Parsing this string value into a numeric value suitable for computation is the responsibility of the application. If the contents are not empty, the result can be parsed successfully by Double.valueOf and related methods if they are present in the runtime environment.

The sign and the fraction separator consume space in the text object. Applications should account for this when assigning a maximum size for the text object.

Constant 5 is assigned to DECIMAL.

Since:
MIDP 2.0
See Also:
Constant Field Values

FIXED_POINT_DECIMAL

public static final int FIXED_POINT_DECIMAL
The user is allowed to enter numeric values with two decimal fractions, for example "-123.00", "0.13", or "0.50".

Numbers are appended in the last decimal fraction by default, so when "1" is pressed this results in "0.01". Similarly pressing "1", "2" and "3" results in "1.23".

Sample usage:

 TextField cashRegister = new TextField("Price: ",  null, 5, UiAccess.CONSTRAINT_FIXED_POINT_DECIMAL );
 

Constant 20 is assigned to FIXED_POINT_DECIMAL.

Since:
J2ME Polish 2.1.3
See Also:
UiAccess.CONSTRAINT_FIXED_POINT_DECIMAL, setNumberOfDecimalFractions(int), getNumberOfDecimalFractions(), convertToFixedPointDecimal(String), Constant Field Values

PASSWORD

public static final int PASSWORD
Indicates that the text entered is confidential data that should be obscured whenever possible. The contents may be visible while the user is entering data. However, the contents must never be divulged to the user. In particular, the existing contents must not be shown when the user edits the contents. The means by which the contents are obscured is implementation-dependent. For example, each character of the data might be masked with a "*" character. The PASSWORD modifier is useful for entering confidential information such as passwords or personal identification numbers (PINs).

Data entered into a PASSWORD field is treated similarly to SENSITIVE in that the implementation must never store the contents into a dictionary or table for use in predictive, auto-completing, or other accelerated input schemes. If the PASSWORD bit is set in a constraint value, the SENSITIVE and NON_PREDICTIVE bits are also considered to be set, regardless of their actual values. In addition, the INITIAL_CAPS_WORD and INITIAL_CAPS_SENTENCE flag bits should be ignored even if they are set.

The PASSWORD modifier can be combined with other input constraints by using the bit-wise OR operator (|). The PASSWORD modifier is not useful with some constraint values such as EMAILADDR, PHONENUMBER, and URL. These combinations are legal, however, and no exception is thrown if such a constraint is specified.

Constant 0x10000 is assigned to PASSWORD.

See Also:
Constant Field Values

UNEDITABLE

public static final int UNEDITABLE
Indicates that editing is currently disallowed. When this flag is set, the implementation must prevent the user from changing the text contents of this object. The implementation should also provide a visual indication that the object's text cannot be edited. The intent of this flag is that this text object has the potential to be edited, and that there are circumstances where the application will clear this flag and allow the user to edit the contents.

The UNEDITABLE modifier can be combined with other input constraints by using the bit-wise OR operator (|).

Constant 0x20000 is assigned to UNEDITABLE.

Since:
MIDP 2.0
See Also:
Constant Field Values

SENSITIVE

public static final int SENSITIVE
Indicates that the text entered is sensitive data that the implementation must never store into a dictionary or table for use in predictive, auto-completing, or other accelerated input schemes. A credit card number is an example of sensitive data.

The SENSITIVE modifier can be combined with other input constraints by using the bit-wise OR operator (|).

Constant 0x40000 is assigned to SENSITIVE.

Since:
MIDP 2.0
See Also:
Constant Field Values

NON_PREDICTIVE

public static final int NON_PREDICTIVE
Indicates that the text entered does not consist of words that are likely to be found in dictionaries typically used by predictive input schemes. If this bit is clear, the implementation is allowed to (but is not required to) use predictive input facilities. If this bit is set, the implementation should not use any predictive input facilities, but it instead should allow character-by-character text entry.

The NON_PREDICTIVE modifier can be combined with other input constraints by using the bit-wise OR operator (|).

Constant 0x80000 is assigned to NON_PREDICTIVE.

Since:
MIDP 2.0
See Also:
Constant Field Values

INITIAL_CAPS_WORD

public static final int INITIAL_CAPS_WORD
This flag is a hint to the implementation that during text editing, the initial letter of each word should be capitalized. This hint should be honored only on devices for which automatic capitalization is appropriate and when the character set of the text being edited has the notion of upper case and lower case letters. The definition of word boundaries is implementation-specific.

If the application specifies both the INITIAL_CAPS_WORD and the INITIAL_CAPS_SENTENCE flags, INITIAL_CAPS_WORD behavior should be used.

The INITIAL_CAPS_WORD modifier can be combined with other input constraints by using the bit-wise OR operator (|).

Constant 0x100000 is assigned to INITIAL_CAPS_WORD.

Since:
MIDP 2.0
See Also:
Constant Field Values

INITIAL_CAPS_SENTENCE

public static final int INITIAL_CAPS_SENTENCE
This flag is a hint to the implementation that during text editing, the initial letter of each sentence should be capitalized. This hint should be honored only on devices for which automatic capitalization is appropriate and when the character set of the text being edited has the notion of upper case and lower case letters. The definition of sentence boundaries is implementation-specific.

If the application specifies both the INITIAL_CAPS_WORD and the INITIAL_CAPS_SENTENCE flags, INITIAL_CAPS_WORD behavior should be used.

The INITIAL_CAPS_SENTENCE modifier can be combined with other input constraints by using the bit-wise OR operator (|).

Constant 0x200000 is assigned to INITIAL_CAPS_SENTENCE.

Since:
MIDP 2.0
See Also:
Constant Field Values

INITIAL_CAPS_NEVER

public static final int INITIAL_CAPS_NEVER
A flag to hint to the implementation that during text editing,the initial letter of each sentence should NOT be capitalized.

See Also:
Constant Field Values

CONSTRAINT_MASK

public static final int CONSTRAINT_MASK
The mask value for determining the constraint mode. The application should use the bit-wise AND operation with a value returned by getConstraints() and CONSTRAINT_MASK in order to retrieve the current constraint mode, in order to remove any modifier flags such as the PASSWORD flag.

Constant 0xFFFF is assigned to CONSTRAINT_MASK.

See Also:
Constant Field Values

CLEAR_CMD

public static Command CLEAR_CMD
Command for clearing the complete text of this field


DELETE_CMD

public static Command DELETE_CMD

caretChar

protected char caretChar

showCaret

protected boolean showCaret

title

protected String title

inputMode

protected int inputMode

symbolsList

protected static List symbolsList

definedSymbols

protected static String[] definedSymbols

ENTER_SYMBOL_CMD

public static Command ENTER_SYMBOL_CMD

MODE_LOWERCASE

public static final int MODE_LOWERCASE
input mode for lowercase characters

See Also:
Constant Field Values

MODE_FIRST_UPPERCASE

public static final int MODE_FIRST_UPPERCASE
input mode for entering one uppercase followed by lowercase characters

See Also:
Constant Field Values

MODE_UPPERCASE

public static final int MODE_UPPERCASE
input mode for uppercase characters

See Also:
Constant Field Values

MODE_NUMBERS

public static final int MODE_NUMBERS
input mode for numeric characters

See Also:
Constant Field Values

MODE_NATIVE

public static final int MODE_NATIVE
input mode for input using a separete native TextBox

See Also:
Constant Field Values

KEY_CHANGE_MODE

public static final int KEY_CHANGE_MODE

KEY_DELETE

public static final int KEY_DELETE
See Also:
Constant Field Values

charactersKey0

protected static String charactersKey0

charactersKeyStar

protected static String charactersKeyStar

charactersKeyPound

protected static String charactersKeyPound

CHARACTERS

public static String[] CHARACTERS
map of characters that can be triggered witht the 0..9 and #, * keys


CHARACTERS_UPPER

public static String[] CHARACTERS_UPPER

usesDynamicCharset

public static boolean usesDynamicCharset

infoItem

protected StringItem infoItem

lock

protected final Object lock

emailSeparatorChar

protected char emailSeparatorChar

flashCaret

protected boolean flashCaret

isUneditable

protected boolean isUneditable
Constructor Detail

FakeTextFieldCustomItem

public FakeTextFieldCustomItem(String label,
                               String text,
                               int maxSize,
                               int constraints)
Creates a new TextField object with the given label, initial contents, maximum size in characters, and constraints. If the text parameter is null, the TextField is created empty. The maxSize parameter must be greater than zero. An IllegalArgumentException is thrown if the length of the initial contents string exceeds maxSize. However, the implementation may assign a maximum size smaller than the application had requested. If this occurs, and if the length of the contents exceeds the newly assigned maximum size, the contents are truncated from the end in order to fit, and no exception is thrown.

Parameters:
label - item label
text - the initial contents, or null if the TextField is to be empty
maxSize - the maximum capacity in characters
constraints - see input constraints
Throws:
IllegalArgumentException - if maxSize is zero or less or if the value of the constraints parameter is invalid or if text is illegal for the specified constraints or if the length of the string exceeds the requested maximum capacity

FakeTextFieldCustomItem

public FakeTextFieldCustomItem(String label,
                               String text,
                               int maxSize,
                               int constraints,
                               Style style)
Creates a new TextField object with the given label, initial contents, maximum size in characters, and constraints. If the text parameter is null, the TextField is created empty. The maxSize parameter must be greater than zero. An IllegalArgumentException is thrown if the length of the initial contents string exceeds maxSize. However, the implementation may assign a maximum size smaller than the application had requested. If this occurs, and if the length of the contents exceeds the newly assigned maximum size, the contents are truncated from the end in order to fit, and no exception is thrown.

Parameters:
label - item label
text - the initial contents, or null if the TextField is to be empty
maxSize - the maximum capacity in characters
constraints - see input constraints
style - the CSS style for this field
Throws:
IllegalArgumentException - if maxSize is zero or less or if the value of the constraints parameter is invalid or if text is illegal for the specified constraints or if the length of the string exceeds the requested maximum capacity
Method Detail

loadCharacterSets

public static void loadCharacterSets(String lowercaseUrl,
                                     String uppercaseUrl)
Reads the .properties files for lowercase and uppercase letters and maps the values of the predefined keys to the character maps. Uses UTF-8 as encoding.

Parameters:
lowercaseUrl - the properties file for lower case
uppercaseUrl - the properties file for upper case

loadCharacterSets

public static void loadCharacterSets(InputStream lowercaseStream,
                                     InputStream uppercaseStream)
Reads the .properties files for lowercase and uppercase letters and maps the values of the predefined keys to the character maps. Uses UTF-8 as encoding.

Parameters:
lowercaseStream - the input stream of properties for lower case
uppercaseStream - the input stream of properties for upper case

loadCharacterSets

public static void loadCharacterSets(String lowercaseUrl,
                                     String uppercaseUrl,
                                     String encoding)
Reads the .properties files for lowercase and uppercase letters and maps the values of the predefined keys to the character maps.

Parameters:
lowercaseUrl - the properties file for lower case
uppercaseUrl - the properties file for upper case
encoding - the encoding to use

loadCharacterSets

public static void loadCharacterSets(InputStream lowercaseStream,
                                     InputStream uppercaseStream,
                                     String encoding)
Reads the .properties files for lowercase and uppercase letters and maps the values of the predefined keys to the character maps.

Parameters:
lowercaseStream - the properties file for lower case
uppercaseStream - the properties file for upper case
encoding - the encoding to use

getString

public String getString()
Gets the contents of the TextField as a string value.

Returns:
the current contents, an empty string when the current value is null.
See Also:
setString(java.lang.String)

getDotSeparatedDecimalString

public String getDotSeparatedDecimalString()
Retrieves the decimal value entered with a dot as the decimal mark.

Returns:
either the formatted value or null, when there was no input.
Throws:
IllegalStateException - when the TextField is not DECIMAL constrained

setString

public void setString(String text)
Sets the contents of the TextField as a string value, replacing the previous contents.

Parameters:
text - the new value of the TextField, or null if the TextField is to be made empty
Throws:
IllegalArgumentException - if text is illegal for the current input constraints or if the text would exceed the current maximum capacity
See Also:
getString()

setNumberOfDecimalFractions

public void setNumberOfDecimalFractions(int number)
Sets the number of decimal fractions that are allowed for FIXED_POINT_DECIMAL constrained TextFields

Parameters:
number - the number (defaults to 2)
See Also:
UiAccess.CONSTRAINT_FIXED_POINT_DECIMAL, FIXED_POINT_DECIMAL

getNumberOfDecimalFractions

public int getNumberOfDecimalFractions()
Retrieves the number of decimal fractions that are allowed for FIXED_POINT_DECIMAL constrained TextFields

Returns:
the number (defaults to 2)
See Also:
UiAccess.CONSTRAINT_FIXED_POINT_DECIMAL, FIXED_POINT_DECIMAL

convertToFixedPointDecimal

protected String convertToFixedPointDecimal(String original)
Converts the given entry into cash format. Subclasses may override this to implement their own behavior.

Parameters:
original - the original text, e.g. "1"
Returns:
the processed text, e.g. "0.01"
See Also:
FIXED_POINT_DECIMAL, UiAccess.CONSTRAINT_FIXED_POINT_DECIMAL, getNumberOfDecimalFractions(), setNumberOfDecimalFractions(int)

updateDeleteCommand

protected void updateDeleteCommand(String newText)

getChars

public int getChars(char[] data)
Copies the contents of the TextField into a character array starting at index zero. Array elements beyond the characters copied are left unchanged.

Parameters:
data - the character array to receive the value
Returns:
the number of characters copied
Throws:
ArrayIndexOutOfBoundsException - if the array is too short for the contents
NullPointerException - if data is null
See Also:
setChars(char[], int, int)

setChars

public void setChars(char[] data,
                     int offset,
                     int length)
Sets the contents of the TextField from a character array, replacing the previous contents. Characters are copied from the region of the data array starting at array index offset and running for length characters. If the data array is null, the TextField is set to be empty and the other parameters are ignored.

The offset and length parameters must specify a valid range of characters within the character array data. The offset parameter must be within the range [0..(data.length)], inclusive. The length parameter must be a non-negative integer such that (offset + length) <= data.length.

Parameters:
data - the source of the character data
offset - the beginning of the region of characters to copy
length - the number of characters to copy
Throws:
ArrayIndexOutOfBoundsException - - if offset and length do not specify a valid range within the data array
IllegalArgumentException - - if data is illegal for the current input constraints or if the text would exceed the current maximum capacity
See Also:
getChars(char[])

insert

public void insert(String src,
                   int position)
Inserts a string into the contents of the TextField. The string is inserted just prior to the character indicated by the position parameter, where zero specifies the first character of the contents of the TextField. If position is less than or equal to zero, the insertion occurs at the beginning of the contents, thus effecting a prepend operation. If position is greater than or equal to the current size of the contents, the insertion occurs immediately after the end of the contents, thus effecting an append operation. For example, text.insert(s, text.size()) always appends the string s to the current contents.

The current size of the contents is increased by the number of inserted characters. The resulting string must fit within the current maximum capacity.

If the application needs to simulate typing of characters it can determining the location of the current insertion point ("caret") using the with getCaretPosition() method. For example, text.insert(s, text.getCaretPosition()) inserts the string s at the current caret position.

Parameters:
src - the String to be inserted
position - the position at which insertion is to occur
Throws:
IllegalArgumentException - if the resulting contents would be illegal for the current input constraints or if the insertion would exceed the current maximum capacity
NullPointerException - if src is null

insert

public void insert(char[] data,
                   int offset,
                   int length,
                   int position)
Inserts a subrange of an array of characters into the contents of the TextField. The offset and length parameters indicate the subrange of the data array to be used for insertion. Behavior is otherwise identical to insert(String, int).

The offset and length parameters must specify a valid range of characters within the character array data. The offset parameter must be within the range [0..(data.length)], inclusive. The length parameter must be a non-negative integer such that (offset + length) <= data.length.

Parameters:
data - - the source of the character data
offset - - the beginning of the region of characters to copy
length - - the number of characters to copy
position - - the position at which insertion is to occur
Throws:
ArrayIndexOutOfBoundsException - - if offset and length do not specify a valid range within the data array
IllegalArgumentException - - if the resulting contents would be illegal for the current input constraints or if the insertion would exceed the current maximum capacity
NullPointerException - - if data is null

delete

public void delete(int offset,
                   int length)
Deletes characters from the TextField.

The offset and length parameters must specify a valid range of characters within the contents of the TextField. The offset parameter must be within the range [0..(size())], inclusive. The length parameter must be a non-negative integer such that (offset + length) <= size().

Parameters:
offset - the beginning of the region to be deleted
length - the number of characters to be deleted
Throws:
IllegalArgumentException - if the resulting contents would be illegal for the current input constraints
StringIndexOutOfBoundsException - if offset and length do not specify a valid range within the contents of the TextField

getMaxSize

public int getMaxSize()
Returns the maximum size (number of characters) that can be stored in this TextField.

Returns:
the maximum size in characters
See Also:
setMaxSize(int)

setMaxSize

public int setMaxSize(int maxSize)
Sets the maximum size (number of characters) that can be contained in this TextField. If the current contents of the TextField are larger than maxSize, the contents are truncated to fit.

Parameters:
maxSize - the new maximum size
Returns:
assigned maximum capacity may be smaller than requested.
Throws:
IllegalArgumentException - if maxSize is zero or less. or if the contents after truncation would be illegal for the current input constraints
See Also:
getMaxSize()

size

public int size()
Gets the number of characters that are currently stored in this TextField.

Returns:
number of characters in the TextField

getCaretPosition

public int getCaretPosition()
Gets the current input position. For some UIs this may block and ask the user for the intended caret position, and on other UIs this may simply return the current caret position. When the direct input mode is used, this method simply returns the current cursor position (= non blocking).

Returns:
the current caret position, 0 if at the beginning

setCaretPosition

public void setCaretPosition(int position)
Sets the caret position. Please note that this operation requires the direct input mode to work.

Parameters:
position - the new caret position, 0 puts the caret at the start of the line, getString().length moves the caret to the end of the input.

setConstraints

public void setConstraints(int constraints)
Sets the input constraints of the TextField. If the the current contents of the TextField do not match the new constraints, the contents are set to empty.

Parameters:
constraints - see input constraints
Throws:
IllegalArgumentException - if constraints is not any of the ones specified in input constraints
See Also:
getConstraints()

activate

public void activate(boolean editable)
Sets a blackberry field to selectable. Used to prevent fields to be selectable if they should not be shown.

Parameters:
editable - true, if the textfield should be selectable, otherwise false

setEditable

public void setEditable(boolean editable)

getConstraints

public int getConstraints()
Gets the current input constraints of the TextField.

Returns:
the current constraints value (see input constraints)
See Also:
setConstraints(int)

setInitialInputMode

public void setInitialInputMode(String characterSubset)
Sets a hint to the implementation as to the input mode that should be used when the user initiates editing of this TextField. The characterSubset parameter names a subset of Unicode characters that is used by the implementation to choose an initial input mode. If null is passed, the implementation should choose a default input mode.

When the direct input mode is used, J2ME Polish will ignore this call completely.

Parameters:
characterSubset - a string naming a Unicode character subset, or null
Since:
MIDP 2.0

paintContent

public void paintContent(int x,
                         int y,
                         int leftBorder,
                         int rightBorder,
                         Graphics g)
Description copied from class: FakeCustomItem
Paints the content of this item. The background has already been painted and the border will be added after this method returns.

Overrides:
paintContent in class FakeStringCustomItem
Parameters:
x - the left start position
y - the upper start position
leftBorder - the left border, nothing must be painted left of this position
rightBorder - the right border, nothing must be painted right of this position
g - the Graphics on which this item should be painted.

initContent

protected void initContent(int firstLineWidth,
                           int availWidth,
                           int availHeight)
Description copied from class: FakeCustomItem
Initialises this item. The implementation needs to calculate and set the contentWidth and contentHeight fields. The implementation should take the fields preferredWidth and preferredHeight into account.

Overrides:
initContent in class FakeStringCustomItem
Parameters:
firstLineWidth - the maximum width of the first line
availWidth - the available maximum width of this item in pixels
availHeight - the available maximum height of this item in pixels
See Also:
FakeCustomItem.contentWidth, FakeCustomItem.contentHeight, FakeCustomItem.preferredWidth, FakeCustomItem.preferredHeight

createCssSelector

protected String createCssSelector()
Description copied from class: FakeCustomItem
Retrieves the CSS selector for this item. The CSS selector is used for the dynamic assignment of styles - that is the styles are assigned by the usage of the item and not by a predefined style-name. With the #style preprocessing command styles are set fix, this method yields in a faster GUI and is recommended. When in a style-sheet dynamic styles are used, e.g. "Form>p", than the selector of the item is needed.
This abstract method needs only be implemented, when dynamic styles are used: #ifdef polish.useDynamicStyles
The returned selector needs to be in lower case.

Overrides:
createCssSelector in class FakeStringCustomItem
Returns:
the appropriate CSS selector for this item. The selector needs to be in lower case.

setStyle

public void setStyle(Style style)
Description copied from class: FakeCustomItem
Sets the style of this item.

Overrides:
setStyle in class FakeStringCustomItem
Parameters:
style - the new style for this item.

setStyle

public void setStyle(Style style,
                     boolean resetStyle)
Description copied from class: FakeCustomItem
Sets the style of this item for animatable CSS attributes.

Overrides:
setStyle in class FakeStringCustomItem
Parameters:
style - the new style for this element.
resetStyle - true when style settings should be resetted. This is not the case when styles are animated, for example.

isValidInput

protected boolean isValidInput(char insertChar,
                               int position,
                               String myText)

commitCurrentCharacter

protected void commitCurrentCharacter()

insertCharacter

protected void insertCharacter(char insertChar,
                               boolean append,
                               boolean commit)

updateInfo

public void updateInfo()
Updates the information text


animate

public void animate(long currentTime,
                    ClippingRegion repaintRegion)
Description copied from class: FakeCustomItem
Animates this item. Subclasses can override this method to create animations. The default implementation animates the background and the item view if present.

Overrides:
animate in class FakeStringCustomItem
Parameters:
currentTime - the current time in milliseconds
repaintRegion - the repaint area that needs to be updated when this item is animated
See Also:
FakeCustomItem.addRelativeToContentRegion(ClippingRegion, int, int, int, int)

animate

public boolean animate()
Description copied from class: FakeCustomItem
Animates this item. Subclasses can override this method to create animations. The default implementation returns false

Overrides:
animate in class FakeCustomItem
Returns:
true when this item has been animated.
See Also:
FakeCustomItem.animate(long, ClippingRegion)

handleKeyPressed

protected boolean handleKeyPressed(int keyCode,
                                   int gameAction)
Description copied from class: FakeCustomItem
Handles the key-pressed event. Please note, that implementation should first try to handle the given key-code, before the game-action is processed. The default implementation just handles the FIRE game-action when a default-command and an item-command-listener have been registered.

Overrides:
handleKeyPressed in class FakeCustomItem
Parameters:
keyCode - the code of the pressed key, e.g. Canvas.KEY_NUM2
gameAction - the corresponding game-action, e.g. Canvas.UP
Returns:
true when the key has been handled / recognized

handleKeyInsert

protected boolean handleKeyInsert(int keyCode,
                                  int gameAction)
Tries to interpret a key pressed event for inserting a character into this TextField.

Parameters:
keyCode - the key code of the event
gameAction - the associated game action
Returns:
true when the key could be interpreted as a character

handleKeyClear

protected boolean handleKeyClear(int keyCode,
                                 int gameAction)

handleKeyMode

protected boolean handleKeyMode(int keyCode,
                                int gameAction)

handleKeyNavigation

protected boolean handleKeyNavigation(int keyCode,
                                      int gameAction)

handleKeyRepeated

protected boolean handleKeyRepeated(int keyCode,
                                    int gameAction)
Description copied from class: FakeCustomItem
Handles the key-repeated event. Please note, that implementation should first try to handle the given key-code, before the game-action is processed. The default implementation forwards the event to the handleKeyPressed method.

Overrides:
handleKeyRepeated in class FakeCustomItem
Parameters:
keyCode - the code of the pressed key, e.g. Canvas.KEY_NUM2
gameAction - the corresponding game-action, e.g. Canvas.UP
Returns:
true when the key has been handled / recognized
See Also:
FakeCustomItem.handleKeyPressed(int, int)

handleKeyReleased

protected boolean handleKeyReleased(int keyCode,
                                    int gameAction)
Description copied from class: FakeCustomItem
Handles the key-released event. Please note, that implementation should first try to handle the given key-code, before the game-action is processed. The default implementation invokes the default command if one is present

Overrides:
handleKeyReleased in class FakeCustomItem
Parameters:
keyCode - the code of the pressed key, e.g. Canvas.KEY_NUM2
gameAction - the corresponding game-action, e.g. Canvas.UP
Returns:
true when the key has been handled / recognized
See Also:
FakeCustomItem.handleKeyPressed(int, int)

handlePointerPressed

protected boolean handlePointerPressed(int x,
                                       int y)
Handles the event when a pointer has been pressed at the specified position. The default method translates the pointer-event into an artificial pressing of the FIRE game-action, which is subsequently handled bu the handleKeyPressed(-1, Canvas.FIRE) method. This method needs should be overwritten only when the "polish.hasPointerEvents" preprocessing symbol is defined: "//#ifdef polish.hasPointerEvents".

Overrides:
handlePointerPressed in class FakeCustomItem
Parameters:
x - the x position of the pointer pressing
y - the y position of the pointer pressing
Returns:
true when the pressing of the pointer was actually handled by this item.
See Also:
this method is used for determining whether the event belongs to this item, for a helper method for determining whether the event took place into the actual content area, FakeCustomItem.handleKeyPressed(int, int), for calculating the horizontal position relative to the content (relX - contentX), for calculating the vertical position relative to the content (relY - contentY)

handlePointerReleased

protected boolean handlePointerReleased(int x,
                                        int y)
Handles the event when a pointer has been pressed at the specified position. The default method translates the pointer-event into an artificial pressing of the FIRE game-action, which is subsequently handled bu the handleKeyPressed(-1, Canvas.FIRE) method. This method needs should be overwritten only when the "polish.hasPointerEvents" preprocessing symbol is defined: "//#ifdef polish.hasPointerEvents".

Overrides:
handlePointerReleased in class FakeCustomItem
Parameters:
x - the x position of the pointer pressing
y - the y position of the pointer pressing
Returns:
true when the pressing of the pointer was actually handled by this item.
See Also:
this method is used for determining whether the event belongs to this item, for a helper method for determining whether the event took place into the actual content area, FakeCustomItem.handleKeyPressed(int, int), for calculating the horizontal position relative to the content (relX - contentX), for calculating the vertical position relative to the content (relY - contentY)

handlePointerDragged

protected boolean handlePointerDragged(int relX,
                                       int relY)
Description copied from class: FakeCustomItem
Handles the dragging/movement of a pointer. This method should be overwritten only when the polish.hasPointerEvents preprocessing symbol is defined. The default implementation returns false.

Overrides:
handlePointerDragged in class FakeCustomItem
Parameters:
relX - the x position of the pointer pressing relative to this item's left position
relY - the y position of the pointer pressing relative to this item's top position
Returns:
true when the dragging of the pointer was actually handled by this item.

showTextBox

protected void showTextBox()
Shows the TextBox for entering texts.


commandAction

public void commandAction(Command cmd,
                          Displayable box)
Description copied from interface: CommandListener
Indicates that a command event has occurred on Displayable d.

Specified by:
commandAction in interface CommandListener
Parameters:
cmd - - a Command object identifying the command. This is either one of the applications have been added to Displayable with addCommand(Command) or is the implicit SELECT_COMMAND of List.
box - - the Displayable on which this event has occurred

setItemCommandListener

public void setItemCommandListener(ItemCommandListener l)
Description copied from class: FakeCustomItem
Sets a listener for Commands to this Item, replacing any previous ItemCommandListener. A null reference is allowed and has the effect of removing any existing listener. When no listener is registered, J2ME Polish notifies the command-listener of the current screen, when an item command has been selected.

It is illegal to call this method if this Item is contained within an Alert.

Overrides:
setItemCommandListener in class FakeCustomItem
Parameters:
l - the new listener, or null.

getItemCommandListener

public ItemCommandListener getItemCommandListener()
Description copied from class: FakeCustomItem
Gets the listener for Commands to this Item. When no listener is registered, null is returned

It is illegal to call this method if this Item is contained within an Alert.

Overrides:
getItemCommandListener in class FakeCustomItem
Returns:
the ItemCommandListener associated with this item

initSymbolsList

public static void initSymbolsList()

commandAction

public void commandAction(Command cmd,
                          Item item)
Description copied from interface: ItemCommandListener
Called by the system to indicate that a command has been invoked on a particular item.

Specified by:
commandAction in interface ItemCommandListener
Parameters:
cmd - the Command that was invoked
item - the Item on which the command was invoked

defocus

protected void defocus(Style originalStyle)
Description copied from class: FakeCustomItem
Removes the focus from this item.

Overrides:
defocus in class FakeStringCustomItem
Parameters:
originalStyle - the original style which will be restored.

focus

protected Style focus(Style focStyle,
                      int direction)
Description copied from class: FakeCustomItem
Focuses this item.

Overrides:
focus in class FakeCustomItem
Parameters:
focStyle - the style which is used to indicate the focused state
direction - the direction from which this item is focused, either Canvas.UP, Canvas.DOWN, Canvas.LEFT, Canvas.RIGHT or 0. When 0 is given, the direction is unknown.
Returns:
the current style of this item

fieldChanged

public void fieldChanged(net.rim.device.api.ui.Field field,
                         int context)
Notifies the TextField about changes in its native BlackBerry component.

Parameters:
field - the native field
context - the context of the change

setInputMode

public void setInputMode(int inputMode)
Sets the input mode for this TextField. Is ignored when no direct input mode is used.

Parameters:
inputMode - the input mode

getInputMode

public int getInputMode()
Returns the current input mode.

Returns:
the current input mode

setShowInputInfo

public void setShowInputInfo(boolean show)
(De)activates the input info element for this TextField. Note that the input info cannot be shown when it is deactivated by setting the "polish.TextField.includeInputInfo" preprocessing variable to "false".

Parameters:
show - true when the input info should be shown

showNotify

protected void showNotify()
Description copied from class: FakeCustomItem
Called by the system to notify the item that it is now at least partially visible, when it previously had been completely invisible. The item may receive paint() calls after showNotify() has been called.

The default implementation of this method sets the isShown field to true and calls showNotify on style elements.

Overrides:
showNotify in class FakeStringCustomItem

hideNotify

protected void hideNotify()
Description copied from class: FakeCustomItem
Called by the system to notify the item that it is now completely invisible, when it previously had been at least partially visible. No further paint() calls will be made on this item until after a showNotify() has been called again.

The default implementation of this method sets the isShown field to false and calls hideNotify on style elements.

Overrides:
hideNotify in class FakeStringCustomItem

getPredictiveAccess

public PredictiveAccess getPredictiveAccess()

setPredictiveAccess

public void setPredictiveAccess(PredictiveAccess predictive)

isSuppressCommands

public boolean isSuppressCommands()
Checks if commands are currently suppressed by this TextField.

Returns:
true when commands are suppressed

setSuppressCommands

public void setSuppressCommands(boolean suppressCommands)
Toggles the surpressing of commands for this TextField This has no effect when commands are globally suppressed by settting the preprocessing variable "polish.TextField.suppressCommands" to "true".

Parameters:
suppressCommands - true when commands should be suppressed

setHelpText

public void setHelpText(String text)
Sets a help text for this TextField. The help text appears when a TextField has no input yet and is used to inform the user about the desired content (e.g. "Insert name here ...")

Parameters:
text - the help text

setHelpStyle

public void setHelpStyle()
Sets the help style for this TextField with the use of style preprocessing e.g.: //#style myStyle setHelpStyle();


setHelpStyle

public void setHelpStyle(Style style)
Sets the style of the help text

Parameters:
style - the style

getInfoItem

public StringItem getInfoItem()
Returns the StringItem which is displaying the input info

Returns:
the StringItem displaying the input info

setInfoItem

public void setInfoItem(StringItem infoItem)
Sets the StringItem which should display the input info

Parameters:
infoItem - the StringItem to display the input info

getDefinedSymbols

public static String[] getDefinedSymbols()
Returns the defined symbols as a String array

Returns:
the string array

updateInternalArea

public void updateInternalArea()
Description copied from class: FakeCustomItem
Updates the internal area on BB and similar platforms that contain native fields.

Overrides:
updateInternalArea in class FakeCustomItem

getPredictiveMatchingWords

public ArrayList getPredictiveMatchingWords()
Retrieves matching words for the specified textfield. Note that you need to enable the predictive input mode using the preprocessing variable polish.TextField.usePredictiveInputMode.

Returns:
ArrayList<String> of allowed words - null when no predictive mode is used

setPredictiveDictionary

public void setPredictiveDictionary(String[] words)
Allows the given words for the specified textfield. Note that you need to enable the predictive input mode using the preprocessing variable polish.TextField.usePredictiveInputMode.

Parameters:
words - array of allowed words - use null to reset the allowed words to the default RMS dictionary

setPredictiveInfo

public void setPredictiveInfo(String info)

setPredictiveWordNotFoundAlert

public void setPredictiveWordNotFoundAlert(Alert alert)
Set the word-not-found box in the textfield

Parameters:
alert - the alert

isCskOpensNativeEditor

public boolean isCskOpensNativeEditor()
Returns true if the flag to open the native editor on CenterSoftKey press is set to true

Returns:
true when the native editor is opened when FIRE is pressed

setCskOpensNativeEditor

public void setCskOpensNativeEditor(boolean cskOpensNativeEditor)
Sets the flag to open the native editor on CenterSoftKey press

Parameters:
cskOpensNativeEditor - true when the native editor should be opened when FIRE is pressed

setTitle

public void setTitle(String title)
Sets the title to be displayed in the native textbox

Parameters:
title - the title to set

setNoComplexInput

public void setNoComplexInput(boolean noComplexInput)
Set if the textfield should accept only simple input.

Parameters:
noComplexInput - set if the textfield should accept only simple input

setNoNewLine

public void setNoNewLine(boolean noNewLine)
Set if the textfield should accept the enter key as an input which results in a new line.

Parameters:
noNewLine - set if new lines should be ignored

isNoNewLine

public boolean isNoNewLine()
Checks if the textfield should accept the enter key as an input which results in a new line.

Returns:
true if new lines should be ignored

isEditable

public boolean isEditable()
Checks if this textfield is edtiable.

Returns:
true when this field is editable