Alert
Alert is a screen that displays data to the user and waits for a period of time before returning to the previous screen.
Alert Type:
Indicates the types of Alert objects to display.
Form
Form is a screen object that can be occupied by other items.
Work steps
Opening Netbeans already installed.
Select File, then select New Project.
Next select Java ME in Categories
Then choose Mobile Application on Project.
Next press the Next button.
After that give the project name.
Then Select Platform in Device Configuration: CLDC-1.0 and Device Profile: MIDP-2.0.
Finish
Program Files
Input :
import javax.microedition.midlet.;
import javax.microedition.lcdui.;
public class Midlet extends MIDlet implements CommandListener {
private Display display;
to display on the desktop
private Form form;
create new coding
private Alert alert;
create for show alert
private Command cmdkeluar;
for command exit
private Command cmdalert;
public Midlet(){
display = Display.getDisplay(this);
form = new Form("Contoh Alert");
form.append("Contoh teks didalam form");
cmdkeluar = new Command("end",Command.EXIT,1);
cmdalert = new Command("alert",Command.SCREEN,2);
form.addCommand(cmdkeluar);
form.addCommand (cmdalert);
form.setCommandListener(this);
}
public void startApp() {
display.setCurrent(form);
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
private void showAlert(){
String info = "ini adalah contoh pesan"+
"atau informasi yang akan"+
"disampaikan kepada user";
# For show massage
alert = new Alert("Informasi",info,null,AlertType.ALARM);
alert.setTimeout(5000);
display.setCurrent(alert, form);
}
public void commandAction(Command c,Displayable s){
if(c == cmdkeluar){
destroyApp(true);
notifyDestroyed();
}else if (c == cmdalert){
showAlert();
}
}
}
Output :
The Final Result
Analysis Program
In this experimental program 4 is a program that uses the Alert object, the following syntax used in this experiment.
private Alert alert;
Syntax used as a Variable of Alert.private Form form;
This syntax is used as a Variable of the Form.
Conclusion
Alert is a screen that displays data to the user and waits for a period of time before returning to the previous screen.
Form is a screen object that can be occupied by other items.
Posted on Utopian.io - Rewarding Open Source Contributors