J2me
public class Pat extends MIDlet { private Display tela; Form form; private Command sair; private Command Calcular; TextField tfRM, tfDisc, tf1tri, tf2tri, tf3tri; Alert alerta; public Image img1,img2;
public Pat() { tela = Display.getDisplay(this); form = new Form("Campo de Texto"); tfRM = new TextField("RM:", "", 10, TextField.NUMERIC); tfDisc = new TextField("Disciplina:", "", 10, TextField.ANY); tf1tri = new TextField("Nota 1:", "", 10, TextField.DECIMAL); tf2tri = new TextField("Nota 2:", "", 10, TextField.DECIMAL); tf3tri = new TextField("Nota 3:", "", 10, TextField.DECIMAL); sair = new Command("Sair", Command.EXIT, 1); Calcular = new Command("Calcular", Command.OK, 1); form.append(tfRM); form.append(tfDisc); form.append(tf1tri); form.append(tf2tri); form.append(tf3tri);
form.addCommand(sair); form.addCommand(Calcular); form.setCommandListener(new CommandListener () {
public void commandAction(Command c, Displayable d){ if (c == sair) { destroyApp(true); notifyDestroyed(); } try{ img1 = Image.createImage("/reprovado.png"); img2 = Image.createImage("/aprovado.png"); } catch(Exception e) {e.printStackTrace();} if(c == Calcular){ int rm = Integer.parseInt(tfRM.getString()); double nota1 = Double.parseDouble(tf1tri.getString()); double nota2 = Double.parseDouble(tf2tri.getString());