Java Reference
In-Depth Information
Introducing the TextField
For user input, the MIDP provides the TextField class. TextField s bear input constraints
that can restrict user input in a variety of ways; for example, it may require that users
enter only numeric input or phone numbers. The TextField class can also format input in
a variety of ways and return only what is input; for example, it might show an entered
phone number as (831) 555-1212, yet report to the application that the entered number
was 8315551212. You set an input constraint using the setConstraints method with a flag
value such as EMAILADDR , NUMERIC , PHONENUMBER , URL , or DECIMAL . These can be accompanied
by additional flags (combined using the bitwise OR operator | ) such as PASSWORD (which
keeps you from seeing the entered text) or UNEDITABLE .
The class also supports the notion of input modes , which let you provide hints to the
implementation regarding how numeric key presses should be mapped to alphanumeric
key presses. You set input modes by specifying the string name for an input mode to the
method setInitialInputMode ; values include the name of Unicode character blocks as
defined by the Java SE class java.lang.Character.UnicodeBlock , which is preceded by the
string UCB_ , as in the following:
UCB_BASIC_LATIN for Latin languages
UCB_GREEK for the Greek language
UCB_CYRILLIC for Cyrillic languages
UCB_HEBREW for Hebrew languages
UCB_ARABIC for Arabic
UCB_THAI for Thai
UCB_HIRAGANA for Japanese Hiragana syllabary
UCB_KATAKANA for Japanese Katakana syllabary
UCB_HANGUL_SYLLABLES for Korean
The MIDP also defines the following specific input modes:
MIDP_UPPERCASE_LATIN for the uppercase characters of Latin languages
MIDP_LOWERCASE_LATIN for the lowercase characters of Latin languages
When creating a TextField , you pass to the constructor the label and default text,
followed by the maximum number of characters the TextField should permit the user to
enter, and finally the constraints (bitwise ORed as appropriate).
 
Search WWH ::




Custom Search