Java Midlet : High Level User Interface

Penggunaan Alert

Contoh Skript :
TV jaman biyen /*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
public class initulisanyangdiketik extends MIDlet implements CommandListener {
Display display;
Form mainForm;
Command exitCommand = new Command(“Exit”, Command.EXIT, 0);
Command okCommand = new Command(“Ok”, Command.OK, 0);
Gauge gauge = new Gauge(null, false, 5, 0);
Command[] commands = {
new Command(“tentang”, Command.OK, 0),
new Command(“jalankan”, Command.OK, 0),
};
Alert[] alerts = {
new Alert(“tentang Alert”,
“Aplikasi ini merupakan contoh alert dengan menggunakan TextBox”,
null, AlertType.ALARM),
new Alert(“jalankan Alert”,
“Telah memasuki menu jalankan”,
null, AlertType.CONFIRMATION),
new Alert(“Info Alert”,
“Example of an INFO type of Alert”,
null, AlertType.INFO),
new Alert(“Warning Alert”,
“Example of an WARNING type of Alert, w/ gauge indicator”,
null, AlertType.WARNING),
new Alert(“Error Alert”,
“Example of an ERROR type of Alert, w/ an ‘OK’ Command”,
null, AlertType.ERROR),
new Alert(“Modal Alert”,
“Example of an modal Alert: timeout = FOREVER”,
null, AlertType.ERROR),
};
public initulisanyangdiketik(){
mainForm = new Form(“JEDI: Alert Example”);
mainForm.addCommand(exitCommand);
for (int i=0; i< commands.length; i++){
mainForm.addCommand(commands[i]);
}
mainForm.setCommandListener(this);
// Menambah sebuah gauge dan menge-set timeout (milliseconds)
alerts[3].setIndicator(gauge);
alerts[3].setTimeout(5000);
// Menambah sebuah command untuk Alert
alerts[4].addCommand(okCommand);
// Menge-Set alert
alerts[5].setTimeout(Alert.FOREVER);
}
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
}
for (int i=0; i
if (c == commands[i]){
display.setCurrent(alerts[i]);
}
}
}
}

Penggunaan List

Contoh Skript :
/*
* ListExample.java
*
* Created on May 15, 2008, 3:27 PM
*/

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

/**
*
* @author user
* @version
*/
public class ListExample extends MIDlet implements CommandListener{
Display display;
List list;
Command exitCommand = new Command(“Exit”, Command.EXIT, 1);
Command newCommand = new Command(“New Item”, Command.OK, 1);
Command renameCommand = new Command(“Rename Item”, Command.OK, 1);
Command deleteCommand = new Command(“Delete Item”, Command.OK, 1);
Ticker ticker = new Ticker(“JENI- Java Education Network Indonesia”);

public ListExample(){
list = new List(“JENI : Contoh List”, List.IMPLICIT);
list.append(“List Item #1”, null);
list.append(“List Item #2”, null);
list.append(“List Item #3”, null);
list.setTicker(ticker);
list.addCommand(exitCommand);
list.addCommand(newCommand);
list.addCommand(renameCommand);
list.addCommand(deleteCommand);
list.setCommandListener(this);
}

public void startApp() {
if (display == null){
display = Display.getDisplay(this);
display.setCurrent(list);
}
}

public void pauseApp() {}

public void destroyApp(boolean unconditional) {}

public void commandAction(Command c, Displayable d){
if (c == exitCommand){
destroyApp(true);
notifyDestroyed(); // Exit
}
if (c == List.SELECT_COMMAND){
int index = list.getSelectedIndex();
String currentItem = list.getString(index);
// menjalankan suatu hal
}
}
}

Date and Time

Contoh Skript :

/*
* DateFieldExample.java
*
* Created on May 15, 2008, 3:36 PM
*/

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

/**
*
* @author user
* @version
*/
public class DateFieldExample extends MIDlet implements CommandListener{
Display display;
Form dateForm;
Command exitCommand = new Command(“Exit”, Command.EXIT, 1);
DateField dateonly,timeonly,datetime;

public DateFieldExample(){
dateForm = new Form(“DateField Modes”);
dateForm.addCommand(exitCommand);
dateForm.setCommandListener(this);
DateField dateonly =
new DateField(“Birthday (DATE)”, DateField.DATE);
DateField timeonly =
new DateField(“Set Alarm (TIME)”, DateField.TIME);
DateField datetime =
new DateField(“Departure (DATE_TIME)”, DateField.DATE_TIME);
dateForm.append(dateonly);
dateForm.append(timeonly);
dateForm.append(datetime);
}

public void startApp() {
if (display == null){
display = Display.getDisplay(this);
display.setCurrent(dateForm);
}
}

public void pauseApp() {}

public void destroyApp(boolean unconditional) {}

public void commandAction(Command c, Displayable d){
if (c == exitCommand){
destroyApp(true);
notifyDestroyed(); // Exit
}
}
}

3 Tanggapan

  1. Pak Suku. Ntu Engine tuk bikin SQL Conection menggunakan net beans berapa ?and JDRE yang berapa jg ?

  2. toeks mas miko, pake aja netBean 5.5 and juga pake JRE 1.5.0_10 dijamin suprot!!..eh suport

  3. apo kau buek ko…pakak ang…

    den hack situs ang ko….

    yang lain buek,karambia cukia

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s

%d blogger menyukai ini: