View Single Post
Old 10-01-2009, 12:56 AM   #6 (permalink)
sahil_khanna
New Member
 
Join Date: Aug 2009
Model: 8300
PIN: N/A
Carrier: None
Posts: 12
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Create a new project and use the following code. Initially, set a breakpoint on the first statement HelloWorld theApp = new HelloWorld(); and debug the application. Also avoid using image at the first go.

Code:
/**
 * HelloWorld.java
 * Copyright (C) 2001-2003 Research In Motion Limited. All rights reserved.
 */
package com.rim.samples.helloworld;

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.*;

/*
 * BlackBerry applications that provide a user interface
 * must extend UiApplication.
 */
public class HelloWorld extends UiApplication
{
        public static void main(String[] args)
        {
                //create a new instance of the application
                //and start the application on the event thread
                HelloWorld theApp = new HelloWorld();
                theApp.enterEventDispatcher();
        }
        
        public HelloWorld()
        {
                //display a new screen
                pushScreen(new HelloWorldScreen());
        }

//create a new screen that extends MainScreen, which provides
//default standard behavior for BlackBerry applications
final class HelloWorldScreen extends MainScreen
{
        public HelloWorldScreen()
        {

                //invoke the MainScreen constructor
                super();

                //add a title to the screen
                LabelField title = new LabelField("HelloWorld Sample", LabelField.ELLIPSIS
                                | LabelField.USE_ALL_WIDTH);
                setTitle(title);

                //add the text "Hello World!" to the screen
                add(new RichTextField("Hello World!"));
        }

        //override the onClose() method to display a dialog box to the user
        //with "Goodbye!" when the application is closed
        public boolean onClose()
        {
            Dialog.alert("Goodbye!");
            System.exit(0);
            return true;
        }

	}
}
Offline   Reply With Quote