/* * 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.Gauge; import java.util.Timer; import java.util.TimerTask; import com.nokia.example.capitals.CapitalMIDlet; /** * Simple screen showing the progress of the connection * to the remote WebService */ public class WaitingScreen extends Screen { private Gauge progressGauge; private Command exitCommand; public WaitingScreen(CapitalMIDlet midlet) { super(midlet); // create displayable Form f = new Form("Calling Web Service"); progressGauge = new Gauge("", false, 10, 0); f.append(progressGauge); displayable = f; // create the timer Timer timer = new Timer(); timer.schedule(new TimerTask() { public void run() { if (progressGauge.getValue() == progressGauge.getMaxValue()) { progressGauge.setValue(0); } else { progressGauge.setValue(progressGauge.getValue() + 1); } } }, 0, 1000); // add commands to the text box exitCommand = new Command("Exit", Command.EXIT, 0); displayable.addCommand(exitCommand); // set command listener displayable.setCommandListener(this); } public void commandAction(Command arg0, Displayable arg1) { midlet.quit(); } }