/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package gui;
import java.util.Timer;
import java.util.TimerTask;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.Gauge;
/**
* asdasfasdf
* @author TeXteR
*/
public class WaitingForm extends Form {
private Gauge gauge;
private boolean done;
private Timer timer;
private WaitFormTimerTask waitFormTimerTask;
public WaitingForm(String title) {
super(title);
gauge = new Gauge("Proszę czekać", false, 100, 0);
timer = new Timer();
waitFormTimerTask = new WaitFormTimerTask(gauge);
append(gauge);
}
public void start() {
timer.schedule(waitFormTimerTask, 0, 10);
}
public void stop() {
timer.cancel();
}
}
class WaitFormTimerTask extends TimerTask {
private int counter = 0;
private Gauge gauge;
public WaitFormTimerTask(Gauge gauge) {
this.gauge = gauge;
}
public void run() {
if (counter + 1 > 100) {
counter = 0;
}
gauge.setValue(counter);
counter++;
}
}