import java.io.*; import javax.microedition.midlet.*; import javax.microedition.lcdui.*; public class TwoGauges extends MIDlet implements CommandListener, ItemStateListener { private Display displayen; private Form formuläret; private Command exitkommandot = new Command("Avsluta", Command.EXIT, 0); Gauge g1 = new Gauge("Ena mätaren", true, 5, 3); Gauge g2 = new Gauge("Andra mätaren", true, 5, 3); public TwoGauges() { formuläret = new Form("Två sammankopplade mätare"); formuläret.append(g1); formuläret.append(g2); formuläret.addCommand(exitkommandot); formuläret.setCommandListener(this); formuläret.setItemStateListener(this); } public void startApp() { displayen = Display.getDisplay(this); displayen.setCurrent(formuläret); } public void commandAction(Command kommandot, Displayable s) { if (kommandot == exitkommandot) { destroyApp(false); notifyDestroyed(); } } public void itemStateChanged(Item i) { if (i == g1) g2.setValue(g1.getValue()); else if (i == g2) g1.setValue(g2.getValue()); } public void destroyApp(boolean unconditional) { } public void pauseApp() { } } // class TwoGauges