Assalamua'laikum wr.wb.
In the Last meeting I have studied about mobile java programming is about Class Alert. An alert is a screen that shows data to the user and waits for a certain period of time before proceeding to the next
The following is an example of script of Class Alert and also our task last meeting in the class of java programming.
1. Main view of simulator aplication . Click on task_alert_modify .
In the Last meeting I have studied about mobile java programming is about Class Alert. An alert is a screen that shows data to the user and waits for a certain period of time before proceeding to the next
Displayable
. An alert can contain a text string and an image. The intended use of Alert
is to inform the user about errors and other exceptional conditions.The following is an example of script of Class Alert and also our task last meeting in the class of java programming.
/*
* 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 JailaniLc
*/
public class Task_alert_modify
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 Task_alert_modify (){
helloAlertString = new
StringItem("This is an example ","of the use of class Alert in
java");
mainForm = new Form("Bahar
Noer", new Item[] { helloAlertString});
mainForm.addCommand(exitCommand);
mainForm.addCommand(whyCommand);
mainForm.setCommandListener(this);
helloAlert = new
Alert("Attention","An alert is a screen that shows data to the
user and waits for a certain period of time before proceeding to the next
Displayable", 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);
}
}
}
Simulator interface :
Picture 1. Main view of simulator aplication |
2. will appear as follow picture. Next, click on "Why ?"...
Picture 2. Appereance of Task_Alert_Modify |
3. Then will appear the Alert of Attention as below.
Picture 3. the alert that appear after click on "Why?". |
May it useful...
thanks. . . :)
thanks. . . :)
Tidak ada komentar:
Posting Komentar