O'Reilly logo

J2ME in a Nutshell by Kim Topley

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 TextFields, 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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required