import javax.microedition.lcdui.*; import javax.microedition.midlet.*; public class Hind1 extends MIDlet implements CommandListener{ TextField tfAeg=new TextField("Aeg", "", 5, TextField.NUMERIC); StringItem vork=new StringItem("Võrk", ""); StringItem vastus=new StringItem("Vastus", ""); String[] vorgud={"EMT", "Tele2", "RLE"}; int[] hinnad={500, 450, 250}; List nimistu=new List("Võrgu valik", List.EXCLUSIVE, vorgud, null); Command c1=new Command("Arvuta", Command.SCREEN, 1); Command c2=new Command("Välju", Command.EXIT, 1); Command c3=new Command("Vali tehe", Command.SCREEN, 2); Command c4=new Command("Lõpeta valimine", Command.SCREEN, 1); Form f=new Form("Arvutaja"); public Hind1(){ f.append(tfAeg); f.append(vork); f.append(vastus); f.addCommand(c1); f.addCommand(c2); f.addCommand(c3); nimistu.addCommand(c4); f.setCommandListener(this); nimistu.setCommandListener(this); Display.getDisplay(this).setCurrent(f); } protected void startApp( ) throws MIDletStateChangeException{} protected void pauseApp( ){} protected void destroyApp( boolean p1 ) throws MIDletStateChangeException{ } public void arvuta(){ int aeg=Integer.parseInt(tfAeg.getString()); int minutiHind=hinnad[nimistu.getSelectedIndex()]; vastus.setText(String.valueOf(aeg*minutiHind)); } public void commandAction( Command p1, Displayable p2 ){ if (p1==c1){ arvuta(); } if(p1==c2){ notifyDestroyed(); } if(p1==c3){ Display.getDisplay(this).setCurrent(nimistu); } if(p1==c4){ vork.setText(nimistu.getString(nimistu.getSelectedIndex())); Display.getDisplay(this).setCurrent(f); } } }