...
import javax.microedition.lcdui.TextField;
...
private Display display;
private Form form;
private Command equal;
private MyCommandListener cl = new MyCommandListener();
private TextField arg1,arg2,action;    //  
...
public void startApp() {

    //   
    display = Display.getDisplay(this);
    form = new Form("Calculator");
    form.setCommandListener(cl);

    // ,  
    equal = new Command("Equal", Command.OK, 1);
    form.addCommand(equal);

    //    
    arg1 = new TextField("Argument1","",5,TextField.NUMERIC);
    form.append(arg1);

    //    
    action = new TextField("Action","",1,TextField.ANY);
    form.append(action);

    //    
    arg2 = new TextField("Argument2","",5,TextField.NUMERIC);
    form.append(arg2);
    display.setCurrent(form);
}

private class MyCommandListener implements CommandListener
{
    public void commandAction(Command c, Displayable d)
    {    
        if(c==equal) {        //  
            //     
            Form resForm = new Form("Result");
            resForm.setCommandListener(cl);
            Command back = new Command("Back",Command.BACK,1);
            resForm.addCommand(back);

            //     
            if(arg1.size()==0 || arg2.size()==0 || action.size()==0) {
                    // ,     
                    resForm.append("Missing argument");
                    //  
                    display.setCurrent(resForm);
                    // 
                    return;
            }

            //   
            char[] act = new char[1];
            action.getChars(act);

            //  
            int first = Integer.parseInt(arg1.getString());
            int second = Integer.parseInt(arg2.getString());
            int res = 0;
            switch(act[0]) {
                //    
                //   
                case '+':
                    res = first + second;
                    break;
                case '-':
                    res = first - second;
                    break;
                case '*':
                    res = first * second;
                    break;
                case '/':
                    res = first / second;
                    break;
                default:
                    // ,   
                    resForm.append("Illegal Operation");
                    //  
                    display.setCurrent(resForm);
                    // 
                    return;
            }

            //        
            resForm.append((new Integer(res)).toString());
            //  
            display.setCurrent(resForm);
        } else
            //  Back    
            //   
            display.setCurrent(form);
    }
}
