/*
 *FormDemo program to show how to use a Form Object
 *written by K. Banerjee
 *j2melbs.com
 */

import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;

public class FormDemo extends MIDlet {

	private Form form;

	private StringItem stringItem;
	private DateField dateField;
	private TextField txtField;
	private ChoiceGroup choiceGroup;

	public FormDemo() {
		
		form = new Form("Your Details");//Construct Form with title

		// a StringItem is not editable
		stringItem = new StringItem("Your Id: ", "WXP-890");
		form.append(stringItem);
		
		//you can also use the shortcut to append a string
		form.append("If your ID is incorrect, call us at xxx-xxx-xxxx");

		// you can accept Date, Time or DateTime formats
		dateField = new DateField("Your DOB: ", DateField.DATE);
		form.append(dateField);

		// to get text input from user
		txtField = new TextField("Your Name: ", "", 50, TextField.ANY);
		form.append(txtField);

		// similar to using a List
		choiceGroup = new ChoiceGroup("Your meals: ",Choice.EXCLUSIVE,new String[] {"Veg", "Non-Veg"}, null);
		form.append(choiceGroup);
	}
	/*
	 *NOTE here we only show the form. In a real application there should be 
	 *code to process the data in the form.
	 **/

	public void startApp() {
		Display display = Display.getDisplay(this);
		display.setCurrent(form);
	}

	public void pauseApp() {}

	public void destroyApp(boolean unconditional) {}
}