/* * Copyright © 2011 Nokia Corporation. All rights reserved. * Nokia and Nokia Connecting People are registered trademarks of Nokia Corporation. * Oracle and Java are trademarks or registered trademarks of Oracle and/or its * affiliates. Other product and company names mentioned herein may be trademarks * or trade names of their respective owners. * See LICENSE.TXT for license information. */ package com.nokia.example.capitals.ui; import javax.microedition.lcdui.Command; import javax.microedition.lcdui.Displayable; import javax.microedition.lcdui.Form; import javax.microedition.lcdui.TextField; import com.nokia.example.capitals.CapitalMIDlet; /** * Main Screen. From this you can select the country and request * the WebService to be called using the country as input */ public class MainScreen extends Screen { private Command exitCommand, callCommand; private TextField textField; public MainScreen(CapitalMIDlet midlet) { super(midlet); // create form textField = new TextField("Country", "", 20, TextField.ANY); Form f = new Form("Capital Service"); f.append(textField); displayable = f; // create command buttons exitCommand = new Command("Exit", Command.EXIT, 0); displayable.addCommand(exitCommand); callCommand = new Command("Retrieve Capital", Command.OK, 0); displayable.addCommand(callCommand); // set command listener displayable.setCommandListener(this); } public void commandAction(Command c, Displayable d) { if (c == exitCommand) { midlet.quit(); } else if (c == callCommand) { if (textField.getString().length() > 0) { // request the midlet to retrive the capital midlet.requestCapital(textField.getString()); } } } }