Hi guys, can anyone spot whats wrong, why does my invocation of 'app.showMessage', not update the screen? I really don't understand screens, an explanation would be much appreciated.
Code:
import net.rim.device.api.ui.*;
import net.rim.device.api.ui.component.*;
import net.rim.device.api.ui.container.*;
import net.rim.device.api.system.*;
public class HelloApp extends UiApplication {
//Screen instance
HelloScreen screen;
public static void main(String argv[]) {
HelloApp app = new HelloApp();
app.enterEventDispatcher();
app.showMessage("Screen updated!");
}
public HelloApp() {
screen = new HelloScreen();
pushScreen(screen);
}
public void showMessage(final String msg){
UiApplication.getApplication().invokeLater(new Runnable() {
public void run(){
//Display dialog with message.
Dialog.alert(msg);
//force repaint of screen.
screen.invalidate();
}
});
}
}//End of Hello App class
class HelloScreen extends MainScreen {
public HelloScreen() {
LabelField title = new LabelField
("Sms reciever", LabelField.ELLIPSIS | LabelField.USE_ALL_WIDTH);
setTitle(title);
RichTextField text = new RichTextField("Waiting for sms...\n");
add(text);
}
}//End of HelloScreen class
---Update---
Just a quick update, it does seem that event dispatcher blocks? If I try the following:
Code:
public static void main(String argv[]) {
HelloApp app = new HelloApp();
app.showMessage("Screen updated 1");
app.enterEventDispatcher();
app.showMessage("Screen updated 2");
}
I get the first dialog message and not the second. Can anyone explain to me why this is? How would I got about getting the second message to display?