import javax.microedition.midlet.*; import javax.microedition.lcdui.*; public class AlertTest extends MIDlet implements CommandListener{ private Display display; // display object private Form Main; // Form private Alert alTest; // an alert private Command exit; // a button to exit //MIDlet constructor public AlertTest(){ display = Display.getDisplay(this); exit = new Command("Exit", Command.SCREEN, 1); Main = new Form("Display Stats"); Main.addCommand(exit); Main.setCommandListener(this); System.out.println("Display "+(display.isColor() ? "does":"does not")+ "support Colour"); System.out.println("Number of colours:"+display.numColors()); } // Start MIDlet public void startApp(){ alTest = new Alert ("Alert", "This alert screen will be followed by the main form", null,null); alTest.setTimeout(Alert.FOREVER); display.setCurrent(alTest, Main); } // pause MIDlet public void pauseApp(){ } //Destroy MIDlet public void destroyApp(boolean unconditional){ } // Check to see if the exit command was selected public void commandAction(Command c, Displayable s){ if (c ==exit){ destroyApp(true); notifyDestroyed(); } } }