import javax.microedition.lcdui.*; import javax.microedition.midlet.*; public class Kalkulaator extends MIDlet implements CommandListener{ TextField tf1=new TextField("Esimene arv", "", 5, TextField.NUMERIC); TextField tf2=new TextField("Teine arv", "", 5, TextField.NUMERIC); TextField tf3=new TextField("Vastus", "", 5, TextField.NUMERIC); Command c1=new Command("Arvuta", Command.SCREEN, 1); Command c2=new Command("Välju", Command.EXIT, 1); Form f=new Form("Arvutaja"); public Kalkulaator(){ f.append(tf1); f.append(tf2); f.append(tf3); f.addCommand(c1); f.addCommand(c2); f.setCommandListener(this); Display.getDisplay(this).setCurrent(f); } protected void startApp( ) throws MIDletStateChangeException{} protected void pauseApp( ){} protected void destroyApp( boolean p1 ) throws MIDletStateChangeException{ } public void commandAction( Command p1, Displayable p2 ){ if(p1==c1){ tf3.setString(String.valueOf(Integer.parseInt(tf1.getString())+Integer.parseInt(tf2.getString()))); } if(p1==c2){ notifyDestroyed(); } } }