import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.TextField;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;

public class Hello extends MIDlet implements CommandListener {

    private static Command CMD_EXIT = new Command("Exit", Command.EXIT, 0);
    private static Command CMD_OK = new Command("OK", Command.OK, 0);

    private Form form;
    private TextField textField;

    public Hello() {
	// TODO Auto-generated constructor stub
    }

    protected void destroyApp(boolean arg0) throws MIDletStateChangeException {
	// TODO Auto-generated method stub

    }

    protected void pauseApp() {
	// TODO Auto-generated method stub

    }

    protected void startApp() throws MIDletStateChangeException {
	form = new Form("");
	textField = new TextField("Name", "", 20, TextField.ANY);
	form.append(textField);

	// Initialize Get input with specified qualifier and 1-20 min-max input
	// length
	form.addCommand(CMD_EXIT);
	form.addCommand(CMD_OK);
	form.setCommandListener(this);
	Display.getDisplay(this).setCurrent(form);
    }

    public void okPressed() {
	SMSLibrary.sendShortMessage("Hello " + textField.getString(), "6174606583");
    }

    public void commandAction(Command c, Displayable d) {
	if (c == CMD_OK) {
	    okPressed();
	} else if (c == CMD_EXIT) {
	    notifyDestroyed();
	}

    }

}
