Text Fields

Text fields are editable areas on a form that can display one or more lines of text. They can be used by app developers to get input from the user. Screenshot shows a text field on a mobile phone. The text field, which has a PASSWORD modifier, is the box beside the item labeled Enter PIN.

Screenshot Text Field on a Form

Java graphics 08fig09.gif


app Developer Responsibilities

MIDP Implementor Responsibilities

  • Any label text
  • Requested size, in characters, of text field
  • Any initial text
  • Any constraints
  • Any modifiers
  • Initial size of the text field
  • Maximum size, in characters, of text fields
  • Stopping users input at text-field capacity
  • Initial position of the caret
  • Whether text is highlighted for overwriting when the user enters the field
  • Whether editing is in-place or off the form
  • Text-display policy (wrapped, clipped, or scroll-through)
  • Traversal method for moving through text
  • Constraint behavior
  • Mask character for PASSWORD modifier
  • Cut, copy, and paste support (optional)

app Developers

Consider: You can add, change, or remove the contents of a text field or its label as needed. Try to do it only when the form is not visible or in response to a user action. Arbitrary changes to visible screens are confusing to users.

Text Field Capacity

Text fields have capacities, which specify the maximum number of characters they can hold.

app Developers

Consider: Set text fields to accept an appropriate number of characters. If you know how much data users will put into a text field, you can make the text field more usable by setting it to accept the correct maximum number of characters. For example, if you have a text field that will hold a password between six and ten characters, set the text field capacity to ten.

If you don't know how many characters a user will be entering, enter the device's maximum number (this is available from the getMaxSize method). If you request a higher capacity than the MIDP implementation can provide, the MIDP implementation's capacity is used. If you are concerned, you can check the capacity of the text field, after your request, to see whether you were able to get the entire amount.

Recommend: Java graphics bulb2_icon.gif Allow the device to determine the physical size of the text field on the display. Do not set a preferred size yourself. (See "Item Sizes" on page 76 for more information.)

MIDP Implementors

Strongly Recommend: Java graphics bulb1_icon.gif Determine and publish the maximum number of characters that your text fields can hold.

Recommend: Java graphics bulb2_icon.gif Use the capacity of a text field to limit the user's input and decrease user error. For example, have the device beep and stop accepting additional input when the user reaches the capacity of the text field.

Recommend: Java graphics bulb2_icon.gif Use the text field's capacity to determine the size to draw the text field on the form. For example, if a text field has a small capacity, you might draw it with only enough space to show the possible characters that it can accept.

Consider: If a text field's capacity is large enough that it can accept multiple lines of input, conserve screen real estate by showing space for only one line of text when the text field is empty. It is easier for the user to see and scroll through the form if the empty field is only one line in height.

Text Field Focus

The issues relating to text field focus include not only how to show that a text field has focus, but also to show whether a text field with focus can be edited on the form, whether a text field that has just gotten focus will have its text highlighted, and so on.

MIDP Implementors

Strongly Recommend: Java graphics bulb1_icon.gif Differentiate between a text field that has focus and one that does not. For example, you could make the outline of a text field that has focus black and put a cursor in the field. In contrast, you could make the outline of a text field that does not have focus a lighter gray line, and not put a cursor in the field. This strategy is shown in Screenshot.

Screenshot Showing Focus for Text Fields

Java graphics 08fig10.gif


Strongly Recommend: Java graphics bulb1_icon.gif Decide whether a text field is edited on the form or off the form in a text box, and publish your decision for app developers. (See for more information on text boxes.)

Strongly Recommend: Java graphics bulb1_icon.gif If the text field will be edited on the form, determine whether you will highlight the contents of the text field for overwriting when the field gets focus. Make your MIDP implementation consistent with the behavior of the device.

Strongly Recommend: Java graphics bulb1_icon.gif If the text field will be edited off the form, the text field on the form should show its entire contents. This keeps the user from having to leave the form to see what is in the text field. If the capacity of the text field is large, the text field can be small when it does not have focus (for example, display a single line of text) but grow to capacity when it has focus.

Strongly Recommend: Java graphics bulb1_icon.gif When a text field is the first visible item on a form, put the focus on that field, show a caret, and be ready to accept input from the user as soon as the screen is displayed.

Screenshot


   
Comments