Jumat, 22 Maret 2013

Java Task (Alert1)

Diposting oleh Unknown di 20.33


INPUT PROGRAM
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package hello;

import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;

/**
 * @author MI
 */
public class TugasMidlet extends MIDlet implements CommandListener {
Display display;
Form mainForm;
StringItem helloAlertString;
Command exitCommand = new Command ("Exit", Command.EXIT,1);
Command whyCommand = new Command ("Why??", Command.OK,1);
Command backCommand = new Command ("Back", Command.BACK,1);
Alert helloAlert;

public TugasMidlet (){
helloAlertString = new StringItem("Welcome ","Java Mobile Programming");
mainForm = new Form("Tugas 1", new Item[] { helloAlertString});
mainForm.addCommand(exitCommand);
mainForm.addCommand(whyCommand);
mainForm.setCommandListener(this);
helloAlert = new Alert("Hello...","Why?? Couse I'm cute", null,AlertType.INFO);
helloAlert.setTimeout(Alert.FOREVER);
helloAlert.addCommand(backCommand);
helloAlert.setCommandListener(this);
}
public void startApp() {
if (display==null){
display = Display.getDisplay(this);
}
display.setCurrent(mainForm);
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
public void commandAction(Command c, Displayable d){
if (c == exitCommand){
destroyApp(true);
notifyDestroyed(); // Exit
}
if (c == whyCommand){
    display.setCurrent(helloAlert,d);
}
if(c == backCommand){
    display.setCurrent(mainForm);
}
}
}

OUTPUT PROGRAM


 

 

0 komentar:

Posting Komentar

 

My PAGES Copyright © 2010 Design by Ipietoon Blogger Template Graphic from Enakei | web hosting