I will show you how to create a basic application for your BlackBerry device. This application will display a simple message "Hello World" on the screen your blackberry.
To do so is needed to install some programs following on your system:
• Sun JDK
• Eclipse SDK,
• BlackBerry JDE Plug-in for Eclipse and
• BlackBerry JDE Component Packs 4.3 - 4.7
To do so is needed to install some programs following on your system:
• Sun JDK
• Eclipse SDK,
• BlackBerry JDE Plug-in for Eclipse and
• BlackBerry JDE Component Packs 4.3 - 4.7
figure 1. |
figure 2 |
Started Making BlackBerry ProjectUntuk setup your new BlackBerry project:
1. Click on File / New / Project menu.
2. Select BlackBerry project (Figure 3).
figure 3 |
3. Click Next.
4. Select the Project name and location (Figure 4)
figure 4 |
5. Enter the name of the project, ie "Hello World".
6. Choose your location or use the default to save your project.
7. Click Finish.
Configure Your New BlackBerry Project
To configure your new BlackBerry project:
1. Click on BlackBerry / Configure Blackberry Workspace.
2. Click on the Workspace BlackBerry and enter vendor and data Version (Figure 5).
6. Choose your location or use the default to save your project.
7. Click Finish.
Configure Your New BlackBerry Project
To configure your new BlackBerry project:
1. Click on BlackBerry / Configure Blackberry Workspace.
2. Click on the Workspace BlackBerry and enter vendor and data Version (Figure 5).
vendor "TestVendor". 3. Here you can change some of the settings are different. Enter the version number 1.0 and 4. From the BlackBerry JDE, select the Installed Componentsfigure 5 |
figure 6 |
5. Select the component packages - 4.6.0 (Figure 6) .6. Click OK.
Creating HelloWorld Class
To start developing our application after creating and configuring Workspace, we need to create a new HelloWorld class:
1. Click File / New / Package (Figure 7) .2. Enter the path that packets com.rim.samples.helloworld.
Creating HelloWorld Class
To start developing our application after creating and configuring Workspace, we need to create a new HelloWorld class:
1. Click File / New / Package (Figure 7) .2. Enter the path that packets com.rim.samples.helloworld.
figure 7 |
3 Click on the button Finish.4. Click File / New / Class (Figure 8)
figure 8 |
figure 9 |
2. Import the net.rim.device.api.ui package, ke sebelah kanan public class HelloWorld line yaitu icon bola lampu yang bercahaya dengan silang merah. Klik disana dan klik Import ‘UiApplication’ (Figure 10).
figure 10 |
3. Anda juga dapat mengetikkan:import net.rim.device.api.ui.UiApplication;
4. Dalam constructor kita akan membuat objek Layar baru dan menampilkannya .
package com.rim.samples.helloworld;
import net.rim.device.api.ui.UiApplication;
public class HelloWorld extends UiApplication
{
public static void main(String[] args)
{
HelloWorld theApp = new HelloWorld();
theApp.enterEventDispatcher();
}
public HelloWorld()
{
//display a new screen pushScreen(new HelloWorldScreen());
}
}
Mainscreen
Mainscreen is a class that provides us with a working area where we can display all the data from our application (in this case the message "Hello World"). Having the title, separator, and the main scrollable.
1. We will add a class that will expand Mainscreen HelloWorldScreen: final class extends HelloWorldScreen MainScreen2. You need to add the import: import net.rim.device.api.ui.container.MainScreen; You can type a line or click on the light bulb icon as described sebelumnya.3. In the constructor of this class we will make a LabelField title, to label Application Kita.
public HelloWorldScreen ()
{
super ();
LabelField title = new LabelField ("HelloWorld Sample",
LabelField.ELLIPSIS | LabelField.USE_ALL_WIDTH);
setTitle (title);
add (new RichTextField ("Hello World!"));
}
4. To import we should add:
net.rim.device.api.ui.component.LabelField import;
net.rim.device.api.ui.component.RichTextField import;
5. Adding a small dialog will appear when the user wants to exit the application. To do so we need to override the OnClose () method of the class HelloWorldScreen: public boolean OnClose ()
{
Dialog.alert ("Goodbye!"); System.exit (0);
return true;
}
6. Once again we need to import the components so we add: import net.rim.device.api.ui.component.Dialog;
7. We can also use a more general approach to import all the components not import one by one:
import net.rim.device.api.ui.component. *;
8. And our application was completed. The complete code is shown below inipackage com.rim.samples.helloworld;
net.rim.device.api.ui.UiApplication import;
import net.rim.device.api.ui.component. *;
net.rim.device.api.ui.container.MainScreen import;
public class HelloWorld extends UIApplication
{
public static void main (String [] args)
{
HelloWorld theApp = new HelloWorld ();
theApp.enterEventDispatcher ();
}
public HelloWorld ()
{
pushScreen (new HelloWorldScreen ());
}
}
final class extends HelloWorldScreen mainscreen
{
public HelloWorldScreen ()
{
super ();
LabelField title = new LabelField ("HelloWorld Sample", LabelField.ELLIPSIS | LabelField.USE_ALL_WIDTH);
setTitle (title);
add (new RichTextField ("Hello World!"));
}
public boolean OnClose ()
{
Dialog.alert ("Goodbye!"); System.exit (0);
return true;
}
}
Running Applications in Simulator
Running the application is quite simple: 1. Click on Run / Run or the green shortcut icon on toolbar.2. You can also choose to click Run / Debug, which will allow you to debug your application, but it also takes longer to load.
3. When you get the simulator (Figure A) locate and run your application from the folder Downloads.4. When you run the application you will see the message "Hello World" (Figure B) .5. And when you click the button out the message "Good Bye" will appear on your screen (Figure C)
6. Close the window to get out of your simulator
gambar A |
Gambar B |
Gambar C |
No comments:
Post a Comment
Terimakasih Sudah berkunjung di blog ecek-ecek ini, semoga artikel yang ada di blog ini dapat membantu anda. Silahkan tinggalkan pesan yang tidak mengandung Spam!!!