Create the Interface

When developing for BlackBerry, you will create the user interface programmatically by creating containers and UI elements as objects and then arranging and connecting them in a hierarchy. First, you need to create a Java class for your simple application.

1. From the File menu, click New and then Package.

2. Enter the name of the package as "com.xplatform.helloworld".

3. Click Finish.

4. From the File menu, click New and then Class.

5. Enter "HelloWorld" as the name of the new class. Leave all other fields with their default values (as shown in Figure 4-5) and click the Finish button.

Figure 4-5. Creating a Java class in Eclipse

Replace the contents of the generated with the source code of the completed Hello World application that follows.

package com.xplatform.helloworld; import net.rim.device.api.ui.*; import net.rim.device.api.ui.component.*; import net.rim.device.api.ui.container.*;

public class HelloWorld extends UiApplication {

public static void main(String []args) {

HelloWorld theApp = new HelloWorld(); theApp.enterEventDispatcher();

public HelloWorld () {

pushScreen (new HelloWorldScreen());

class HelloWorldScreen extends MainScreen {

public HelloWorldScreen() {

LabelField title = new LabelField("XPlatform Dev"); setTitle(title);

add(new RichTextField("Hello World!"));

public boolean onClose() {

System.exit(0); return true;

Was this article helpful?

0 0
iPhone and iPad App Cash

iPhone and iPad App Cash

Discover how a single application could generate $1000's of dollars, instantly. The simple, low cost system for outsourcing app development to freelancers. How to quickly evaluate applications so you can create a high profit one of your very own. The fastest way to leverage the popularity of iPhone and iPad apps to skyrocket your income. Top methods for promoting your application for maximum exposure.

Get My Free Ebook

Post a comment