Discussion Board

Results 1 to 4 of 4

Thread: thread sleep

  1. #1
    Registered User nodevelop's Avatar
    Join Date
    Mar 2003
    Posts
    37
    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

  2. #2
    Registered User doctordwarf's Avatar
    Join Date
    Jul 2003
    Location
    Finland, Tampere
    Posts
    1,113
    nodevelop

    It works. It just does a bit different than in an applet

    Some phones (also Nokia's Series 40, Series 60) have internally double buffered screens.

    That is, nothing is actually drawn until paint() method finishes

  3. #3
    Super Contributor shmoove's Avatar
    Join Date
    Mar 2003
    Location
    Israel
    Posts
    2,280

  4. #4
    Registered User nodevelop's Avatar
    Join Date
    Mar 2003
    Posts
    37
    thanks


    eml

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved