Search code examples
blackberryjava-mecldc

Trying to write a hello world CLDC blackberry program


I got the book Advance Black Berry 6 Development. I was able to get the midlet example to work, but not the first example for a CLDC program. It seems like it never gets to the code and when I run the app I get a blank white screen. I tried to put a break point but it never went off.

Here is the code

package test.org;
import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.component.*;
import net.rim.device.api.ui.container.*;

public class cHelloUniverses extends  UiApplication{


    public static void main(String[] args)
     {
         (new cHelloUniverses()).start();
     }


    public void start()
 {
     MainScreen main = new MainScreen();
     LabelField label= new LabelField("Hello Ted");
     main.add(label);

     UiApplication app = UiApplication.getUiApplication();
     app.pushScreen(main);
     app.enterEventDispatcher();

 }


}

Solution

  • Replace your start() method with this:

    public void start()
     {
         MainScreen main = new MainScreen();
         LabelField label= new LabelField("Hello Ted");
         main.add(label);
    
         this.pushScreen(main);
         this.enterEventDispatcher();
    
     }