When will the repaint method of Form in LWUIT be triggered

79 views Asked by At

I was using LWUIT to develop a Xlet project in a emulator. The project is multiple threaded, when one of the thread finish its work then die or just enter the wain() state, the repaint() method of displaying form will be called and the screen will flash (white screen for a shot time then back to normal).

Part of the code below:

public class LwuitWhiteScreenXlet implements Xlet {
    private Image bgImage;
    Form form;
    Thread thread;
    public void destroyXlet(boolean arg0) throws XletStateChangeException {
            // TODO Auto-generated method stub

    }

    public void initXlet(XletContext arg0) throws XletStateChangeException {
        form = new Form();
    /*Form initialize, code omitted*/
    }

    public void pauseXlet() {
        // TODO Auto-generated method stub

    }

    public void startXlet() throws XletStateChangeException {
    System.out.println("Xlet startXlet START++++++++++++++++++++");
    thread = new Thread((new Runnable() {
        public void run() {
        Image image = null;
        try {
            image = Image.createImage("/res/arrow.png");
        } catch (IOException e) {
            e.printStackTrace();
        }
        Label labelTmp = new AnimatedLabel(image, 3);
        }
    }));
    thread.start();
    form.show();
    System.out.println("Xlet startXlet END ------------------");
    }
}

Has anyone encountered this problem too?

1

There are 1 answers

0
Shai Almog On

You are changing LWUIT code off the EDT which isn't allowed and isn't supported. I suggest looking at implementing the Animation interface and using registerAnimated() in Form.