Name
TextField
Synopsis
TextField
is an Item
that may be placed on
a Form
to display and allow the editing of a text string. The
initial content of a TextField
is set at construction time
or by using the setString()
method and the possibly modified value can be retrieved at any time by calling
getString()
. A TextField
may initially appear as a
single-line control in the user interface, but multi-line input is permitted and
some devices may provide a separate full-screen editor that can be invoked by user action
to make it easier for the user to edit the field content.
Two types of constraint may be applied to the string displayed by a TextField
-
a length constraint and a content constraint.
The maximum size of the text that may appear in
the field is set at construction time and can subsequently be changed using
setMaxSize()
. The implementation may impose a fixed upper limit on all
TextField
s, which overrides the value requested by application code. The
actual maximum size can be obtained from the getMaxSize()
method. The maximum
size is applied whenever the content of the field is changed, whether programmatically or
by the user.
A content constraint can be applied either at construction time or using the
setConstraints()
method to limit the type of data that the
field may contain. When a constraint is in place, the TextField
ensures that each character entered is consistent with the constraint and will reject characters that are not permitted. Constraints are applied both during ...
Get J2ME in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.