Tuesday, December 11, 2012
Memperoleh nilai properti MIDlet pada JAVA (J2ME)
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
public class PropertiMIDlet extends MIDlet
implements CommandListener {
private Display display;
private Form form;
private StringBuffer sb;
private final Command cmdKeluar =
new Command("Keluar", Command.EXIT, 1);
public PropertiMIDlet() {
display = Display.getDisplay(this);
form = new Form("Properti MIDlet");
form.addCommand(cmdKeluar);
form.setCommandListener(this);
}
public void startApp() {
sb = getAppProperties();
StringItem si = new StringItem(null, sb.toString());
form.append(si);
display.setCurrent(form);
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
public void commandAction(Command c, Displayable s) {
if (c == cmdKeluar) {
destroyApp(false);
notifyDestroyed();
}
}
private StringBuffer getAppProperties() {
StringBuffer temp = new StringBuffer();
temp.append("Nama MIDlet: " +
getAppProperty("MIDlet-Name"));
temp.append("\nVersi: " +
getAppProperty("MIDlet-Version"));
temp.append("\nVendor: " +
getAppProperty("MIDlet-Vendor"));
temp.append("\nUkuran: " +
getAppProperty("MIDlet-Jar-Size"));
temp.append("\nURL: " +
getAppProperty("MIDlet-Jar-URL"));
return temp;
}
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment