The thread that takes care of refreshing the screen is the UI thread. It is the same thread that runs commandAction(), itemStateChaged() on Screens, and paint(), keyPressed(), keyReleased(), etc. on Canvases. So if you're doing lengthy processing in those methods and they are the ones changing the displayable then the change will take some time to take effect. Instead run the lengthy processes in a new thread.
For example:
Code:
public void commandAction(Command c, Displayable d) {
if (c == someCommand) {
Display.getDisplay(myMIDlet).setCurrent(someNewScreen);
aFunctionThatTakesALongTime();
}
}
In this code the displayable won't change until aFunctionThatTakesALongTime() returns, because aFunctionThatTakesALongTime() is running in the UI thread. Instead you should do something like:
Code:
public void commandAction(Command c, Displayable d) {
if (c == someCommand) {
Display.getDisplay(myMIDlet).setCurrent(someNewScreen);
Thread t = new Thread(this);
t.start();
}
}
public void run() {
aFunctionThatTakesALongTime();
}
This way you start a new thread to perform the lengthy function and set the UI thread free and able to take care of the call to setCurrent().
shmoove