1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
| import java.util.Timer;
import javax.microedition.lcdui.*;
public class Moteur extends Canvas{
private Timer _timer;
private MyTimerTask _myTimerTask;
private Testeur _testeur;
public Moteur(Testeur t) {
_testeur = t;
_timer = new Timer();
_myTimerTask = new MyTimerTask(this);
}
public void paint(Graphics g) {
if (_testeur.getStatut()==0){
intro(g);
}else if (_testeur.getStatut()==1){
suite(g);
}
}
private void intro(Graphics g){
g.setColor(0,0,0);
// Noir
g.fillRect(0, 0, 128, 142);
// Dessine un rectangle 128*142 rempli en noir
g.setColor(255,0,0);
// Rouge
g.drawString("Veuillez patienter", 0, 0, Graphics.TOP|Graphics.LEFT);
// Ecrit la chaine en rouge
g.drawString("5 secondes...", 0, 15, Graphics.TOP|Graphics.LEFT);
_timer.schedule(_myTimerTask, 5000); //ici je dis de faire une pause de 5000 ms en utilisant ma classe myTimerTask
}
private void suite(Graphics g){
g.setColor(0,0,0);
g.fillRect(0, 0, 100, 100);
g.setColor(255,0,0);
g.drawString("Merci d'avoir", 0, 0, Graphics.TOP|Graphics.LEFT);
g.drawString("patienté.", 0, 15, Graphics.TOP|Graphics.LEFT);
}
public void action(){
_testeur.setStatut(1);
repaint();
}
} |
Partager