hi,
what's wrong with this code?
paint() method shows rects all togheter in the same time.
why Thread.sleep() doesn't work?
(the same paint method used in an applet works well.)
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
public class M1 extends MIDlet {
private Schermo1 mioSchermo = new Schermo1();
public void startApp() {
Display.getDisplay(this).setCurrent(mioSchermo);
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
}
class Schermo1 extends Canvas implements CommandListener {
int y = 10;
public void commandAction(Command c, Displayable mioSchermo){
}
public void paint(Graphics g) {
try {
for (int n = 5; n > 0; n--) {
y = y + 10;
g.setColor(100 + y,100 + y,50 + y);
g.fillRect(y, y, 50, 50);
Thread.sleep(1000);
}
} catch (InterruptedException e) {}
}
}
thanx
eml

Reply With Quote


