Mega Code Archive

 
Categories / Java Tutorial / J2ME
 

Use active and inactive Gauge

import javax.microedition.lcdui.Command; import javax.microedition.lcdui.CommandListener; import javax.microedition.lcdui.Display; import javax.microedition.lcdui.Displayable; import javax.microedition.lcdui.Form; import javax.microedition.lcdui.Gauge; import javax.microedition.midlet.MIDlet; public class J2MEActiveInactiveGaugeMIDlet extends MIDlet implements CommandListener {   private Command exitCommand = new Command("exit", Command.EXIT, 1);   private Gauge activeGauge = new Gauge("active:", true, 10, 2);   private Gauge inactiveGauge = new Gauge("inactive:", false, 10, 4);   private Display display = Display.getDisplay(this);   public void startApp() {     Form aForm = new Form("Gauge");     aForm.append(activeGauge);     aForm.append(inactiveGauge);     aForm.addCommand(exitCommand);     aForm.setCommandListener(this);     display.setCurrent(aForm);   }   public void pauseApp() {   }   public void destroyApp(boolean unconditional) {   }   public void commandAction(Command c, Displayable s) {     if (c == exitCommand) {       destroyApp(false);       notifyDestroyed();     }   } }