import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
public class ContohTicker3 extends MIDlet
implements CommandListener {
private Display display;
private Form formMenu;
private Form formInfo;
private Ticker ticker;
private ChoiceGroup pilihan;
private StringItem deskripsi;
private String teksTicker =
"Delphi, C++Builder, dan JBuilder...";
private String infoDelphi =
"Delphi adalah development tool buatan Borland " +
"yang menggunakan bahasa Object Pascal";
private String infoCppBuilder =
"C++Builder adalah development tool buatan Borland " +
"yang menggunakan bahasa C++";
private String infoJBuilder =
"JBuilder adalah development tool buatan Borland " +
"yang menggunakan bahasa Java";
private String[] menu = {
"Delphi",
"C++Builder",
"JBuilder"
};
private final Command cmdKeluar =
new Command("Keluar", Command.EXIT, 1);
private final Command cmdPilih =
new Command("Pilih", Command.OK, 1);
private final Command cmdKembali =
new Command("Kembali", Command.BACK, 1);
public ContohTicker3() {
display = Display.getDisplay(this);
}
public void startApp() {
formMenu = new Form("Contoh Ticker ke-3");
ticker = new Ticker(teksTicker);
formMenu.setTicker(ticker);
pilihan = new ChoiceGroup("Development Tool:",
Choice.EXCLUSIVE, menu, null);
formMenu.append(pilihan);
formMenu.addCommand(cmdKeluar);
formMenu.addCommand(cmdPilih);
formMenu.setCommandListener(this);
formInfo = new Form("Informasi");
deskripsi = new StringItem(null, null);
formInfo.setTicker(ticker); // baris yang ditambahkan
formInfo.append(deskripsi);
formInfo.addCommand(cmdKembali);
formInfo.setCommandListener(this);
display.setCurrent(formMenu);
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
public void commandAction(Command c, Displayable s) {
if (c == cmdKeluar) {
destroyApp(false);
notifyDestroyed();
} else if (c == cmdPilih) {
switch (pilihan.getSelectedIndex()) {
case 0: deskripsi.setText(infoDelphi); break;
case 1: deskripsi.setText(infoCppBuilder); break;
case 2: deskripsi.setText(infoJBuilder); break;
}
display.setCurrent(formInfo);
} else if (c == cmdKembali) {
display.setCurrent(formMenu);
}
}
}
No comments:
Post a Comment