1 package autol;
2 import javax.microedition.midlet.MIDlet;
3 import javax.microedition.midlet.MIDletStateChangeException;
4 import javax.microedition.lcdui.*;
5 import counterWidgets.*;
6
7
16 public class AutolMidlet extends MIDlet implements Counter.ChangeCommandListener {
17
18 private Display display;
19 private Form form;
20 private Counter counterHA;
21 private Counter counterKA;
22 private Counter counterYht;
23 private Button buttonNollaa;
24
25
28 public AutolMidlet() {
29 display = Display.getDisplay(this);
30 form = new Form("Autolaskuri");
31
32 counterYht = new Counter("Yhteensä"); form.append(counterYht);
33 counterHA = new CounterButton("Henkilöautoja"); form.append(counterHA);
34 counterHA.setChangeCommandListener(this);
35 counterKA = new CounterButton("Kuorma-autoja"); form.append(counterKA);
36 counterKA.setChangeCommandListener(this);
37 buttonNollaa = new ResetButton(form,"Nollaa"); form.append(buttonNollaa);
38 }
39
40
43 protected void destroyApp(boolean arg0) throws MIDletStateChangeException {
44 display.setCurrent(null);
45 notifyDestroyed();
46 }
47
48
51 protected void pauseApp() {
52 }
53
54
57 protected void startApp() throws MIDletStateChangeException {
58 display.setCurrent(form);
59 }
60
61
68 public void commandChange(Counter it, int diff) {
69 counterYht.inc(diff);
70 }
71
72 }
73