Java Reference
In-Depth Information
Figure 6-7.
A form with a single TextField and a Back command
TextFields
can limit input. The following constants are defined:
•
ANY
allows any type of input.
•
NUMERIC
restricts the input to numbers.
•
DECIMAL
allows numbers with fractional parts.
•
PHONENUMBER
requires a telephone number.
•
EMAILADDR
input must be an e-mail address.
•
URL
input must be a URL.
These input constraints might look familiar; they're the same ones used by
TextBox
, which
we covered in the previous chapter. As with
TextBox
, the flags
PASSWORD
,
SENSITIVE
,
UNEDITABLE
,
NON_PREDICTIVE
,
INITIAL_CAPS_WORD
, and
INITIAL_CAPS_SENTENCE
can be combined with
constraints using the
OR
operator.
To create a
TextField
, you need to supply the label, text value, maximum length, and input
constraints.
public TextField(String label, String text, int maxSize, int constraints)
For an initially empty
TextField
, pass
null
for the
text
parameter.
As with
TextBox
, the
TextField
class includes a
setInitialInputMode()
method for suggesting
to the implementation an appropriate input mode.
ImageItem
Forms can also contain images, which are represented by instances of
ImageItem
.
ImageItem
s
have several pieces of associated data:
•A
label
may be displayed with the image.
•
The
layout
determines the placement of the image.
•
Alternate text
is displayed if the image cannot be shown.
Search WWH ::
Custom Search