BlackBerry Forums Support Community
              

Closed Thread
 
Thread Tools
Old 05-05-2008, 07:52 PM   #1
skynetchris
Knows Where the Search Button Is
 
Join Date: Apr 2008
Model: 7100T
PIN: N/A
Carrier: optus
Posts: 24
Default Screen not updating

Please Login to Remove!

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?

Last edited by skynetchris; 05-05-2008 at 09:39 PM.. Reason: Update
Offline  
Old 05-06-2008, 02:29 AM   #2
simon.hain
CrackBerry Addict
 
Join Date: Apr 2005
Location: hamburg, germany
Model: 8900
Carrier: o2
Posts: 838
Default

if you use dialog you push a new, modal screen. you don't have to invalidate your screen as there is nothing changed on it.

Quote:
public void enterEventDispatcher()
Enters the event dispatcher.

The thread that calls this method (typically the main thread in the application) becomes the event-dispatching thread, which will execute all drawing and event-handling code.

Note that under normal circumstances this method does not return.
As the method does not return everything below is never executed. Put your code into the constructor of your application to get it executed.
__________________
java developer, Devinto, hamburg/germany
Offline  
Closed Thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


4 Count Case GE ProLine 2 Bulb 120V T12 Electronic Fluorescent Light Ballasts picture

4 Count Case GE ProLine 2 Bulb 120V T12 Electronic Fluorescent Light Ballasts

$49.99



Philips ADVANCE AmbiStar RELB-2S40-N Replacement Ballast 40-Watt 2-Lamp T12 picture

Philips ADVANCE AmbiStar RELB-2S40-N Replacement Ballast 40-Watt 2-Lamp T12

$18.79



Advance No Dimming Rapid Start 277V 215 Lamp Watt Magnetic Ballast VC-2S102-TP picture

Advance No Dimming Rapid Start 277V 215 Lamp Watt Magnetic Ballast VC-2S102-TP

$47.49



Fulham Pony Solid State electronic ballast picture

Fulham Pony Solid State electronic ballast

$15.00



Sylvania OSRAM 51473 -No Leads- QHE 2x28T5/UNV PSN 120/277V Ballast (20 Case) picture

Sylvania OSRAM 51473 -No Leads- QHE 2x28T5/UNV PSN 120/277V Ballast (20 Case)

$283.50



Lot Of 3 Philips Advance ICN-2S110-SC Ballast ICN2S110SC picture

Lot Of 3 Philips Advance ICN-2S110-SC Ballast ICN2S110SC

$45.99







Copyright © 2004-2016 BlackBerryForums.com.
The names RIM © and BlackBerry © are registered Trademarks of BlackBerry Inc.