/*
 *ListDemo program to show how to use a javax.microedition.lcdui.List Object
 *written by K. Banerjee
 *j2melbs.com
 */
 
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;


public class ListDemo extends MIDlet {

	List fruitList1;
	List fruitList2;
	
	public ListDemo() {
		/*We shall first create fruitList1 and then add the elements*/
		fruitList1 = new List("Select the fruits you like", Choice.MULTIPLE);
		fruitList1.append("Orange", null);
		fruitList1.append("Apple", null);
		fruitList1.insert(1, "Guava", null);	// inserts between Orange and Apple
		
		/*We shall first create the elements and then construct fruitList2*/
		String fruits[] = {"Mango", "Berry", "Jackfruit"};
		fruitList2 = new List("Select the fruits you like - List 2", Choice.IMPLICIT, fruits, null);
	}
	
	public void startApp() {
		Display display = Display.getDisplay(this);
		display.setCurrent(fruitList1);
	
		try{
			//We make the current thread sleep for 5 seconds so that you can observe both type of lists
			Thread.currentThread().sleep(5000);
		} 
		catch(Exception e) {}
	
		display.setCurrent(fruitList2);
		/*
		 *NOTE how the appearance of the List changes depending on whether 
		 *it is IMPLICIT or MULTIPLE
		 *Also try the option of EXCLUSIVE
		 **/
	}
	
	public void pauseApp() {}
	
	public void destroyApp (boolean unconditional) {}
}
  