// this project contains a midlet a few commands import javax.microedition.midlet.*; import javax.microedition.lcdui.*; public class MoreCommand extends MIDlet implements CommandListener{ // declare objects private Display display; // display object private Form Main; // Form private TextBox tbLoad; // text for upload and download private Command Exit; private Command Back; private Command ULoad; private Command DLoad; String s1 = "UPload"; // define a string String s2 = "DOWNload"; // constructure public MoreCommand(){ display = Display.getDisplay(this); // initiate commands Exit = new Command("Exit", Command.EXIT, 1); Back = new Command("Back", Command.BACK, 1); ULoad = new Command (s1, Command.SCREEN, 2); DLoad = new Command (s2, Command.SCREEN, 3); // create form - add commands - listen for events Main = new Form ("J2ME More Commands"); Main.addCommand(Exit); Main.addCommand(ULoad); Main.addCommand(DLoad); Main.setCommandListener(this); // create textbox - add command - listen for events tbLoad = new TextBox("Process Info", "Upload/Download data", 30,0); tbLoad.addCommand(Back); tbLoad.setCommandListener(this); } // Start Midlet public void startApp(){ display.setCurrent(Main); } public void pauseApp(){ } public void destroyApp(boolean unconditional){ } // process events public void commandAction(Command c, Displayable s){ if (c == Exit){ destroyApp(false); notifyDestroyed(); } else if (c == ULoad || c == DLoad) display.setCurrent(tbLoad); else if (c == Back) display.setCurrent(Main); } }