/* creating an Alert with an image */ import java.io.*; import javax.microedition.midlet.*; import javax.microedition.lcdui.*; public class ModalAlert extends MIDlet implements CommandListener{ private Display display; // refernce to a Display private Form fmMain; // main form private Alert myAlert; // alert private Command cmExit; // Exit command public ModalAlert(){ display = Display.getDisplay(this);//////MARYAM cmExit = new Command ("Exit", Command.EXIT, 1); fmMain = new Form("Form"); fmMain.append("This a message for you!"); fmMain.addCommand(cmExit); fmMain.setCommandListener(this); } // startApp() public void startApp(){ // Refer to a showAlert class showAlert(); display.setCurrent( myAlert,fmMain); } // pauseApp() public void pauseApp(){ } //App showAlert public void showAlert(){ try { // create an image Image im = Image.createImage("/Resources/logo.png"); // create Alert, add text and image myAlert = new Alert("My Alert", "Time 4 MC!", im, AlertType.INFO); // set alert to type modal myAlert.setTimeout(Alert.FOREVER); } catch(Exception ex){ System.out.println("Unable to locate the png file"); ex.printStackTrace(); return; } // Display the Alert, once dismissed show form display.setCurrent(myAlert, fmMain); } // destroyApp() public void destroyApp(boolean unconditional){ } public void commandAction (Command c, Displayable s){ if(c == cmExit){ destroyApp(true); notifyDestroyed(); } } }