package com.mot.labs.ucsl.j2me.sample;

import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.List;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;

public class HelloWorld extends MIDlet implements CommandListener {

	private Display d;
	private List l;
	
	public HelloWorld() {
		super();
		d = Display.getDisplay(this);
		l = new List("LocationPresence:", List.IMPLICIT);
		l.append("Hello World", null);
		Command ec = new Command("Exit", Command.ITEM,2);
		l.addCommand(ec);
		l.setCommandListener(this);
		
	}
	
	public void commandAction(Command c, Displayable d) {
		if (c.getLabel().equals("Exit")) {
			try {
				this.destroyApp(true);
				notifyDestroyed();
			}
			catch(Exception e) {
				e.printStackTrace();
			}
		}
	
	}

	protected void startApp() throws MIDletStateChangeException {
		d.setCurrent(l);
	}

	protected void pauseApp() {

	}

	protected void destroyApp(boolean arg0) throws MIDletStateChangeException {

	}

}
