Lists (Cont.)
Form form = new Form("Form for Stuff");
form.append(gauge);
form.append(textfield);
The method public int javax.microedition.lcdui.Form.append(Item item) adds an Item
into the Form
.
An Item is a superclass for components that can be added to a Form
and Alert
.
DateField date = new DateField( "Today's date: ", DateField.DATE );
- The class javax.microedition.lcdui.DateField is an editable component for presenting date and time (calendar) information that may be placed into a
Form
.
- The constructor public DateField(String label, int mode) creates a
DateField
object with the following parameters:
label
— the item label.
mode
— the input mode, one of the following three modes:
DATE
— allows to set only date information.
TIME
— allows to set only time information (hours, minutes).
DATE_TIME
— allows to set both clock time and date values.
List down = (List) display.getCurrent( );
switch( down.getSelectedIndex( ) ) {
The method public int getSelectedIndex( ) returns the index number of an element in the Choice that is selected.
For Choice
types EXCLUSIVE and IMPLICIT there is at most one element selected, so this method is useful for determining the user's choice.