Monday, December 3, 2012

Membuat objek Gauge pada JAVA (J2ME)

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

public class DemoGauge extends MIDlet
  implements CommandListener {
   
  private Display display;
  private Form form;
  private Gauge gInteraktif, gNonInteraktif;
 
  private final Command cmdKeluar =
    new Command("Keluar", Command.EXIT, 1);
 
  public DemoGauge() {
    display = Display.getDisplay(this);
   
    form = new Form("Demo Gauge");
    form.addCommand(cmdKeluar);
    form.setCommandListener(this);
   
    gInteraktif = new Gauge("Interaktif", true, 10, 0);
    form.append(gInteraktif);
   
    gNonInteraktif = new Gauge("Non-interaktif", false, 10, 0);
    form.append(gNonInteraktif);
   
  }
   
  public void startApp() {                
    display.setCurrent(form);
  }
   
  public void pauseApp() {
  }
   
  public void destroyApp(boolean unconditional) {
  }
   
  public void commandAction(Command c, Displayable s) {
    if (c == cmdKeluar) {
      destroyApp(false);
      notifyDestroyed();
    }
  } 
}

No comments:

Post a Comment