To this tutorial, you need the software and resources listed below.
Take the following steps to install the SMSComposerExample application:
to Run the main project. Alternatively you could select Run > Run Main Project.
Software or Resource | Version Required |
---|---|
NetBeans IDE with Java ME | Version 6.9 and later |
Java Development Kit (JDK) | Version 6 and version 7 |
Installing and Running the Sample Application
Before we begin, you might want to see final result of the tutorial.Take the following steps to install the SMSComposerExample application:
- Download SMSComposerExample.zip.
- Unzip the file.
- In the IDE, choose File > Open Project and browse to the folder that contains the unzipped files with the SMSComposerExample project.
- Click Open Project.
The Projects window should look like the following: - In the Projects window, right-click the project node and choose Run Project (or press F6).
As the application runs, an emulator window opens and displays the application running in the default device emulator. - In the Emulator window, click the button underneath "Launch". The emulator displays a Splash Screen component then SMS Composer, as shown:
- Move the cursor up and down to navigate through available options like Phone Number or Message.
- Click the central button to enable the selected text field for editing.
- Click the button underneath "Send" to send the message.
- Click the button underneath "Exit" to close the application.
Creating an Application with the SMS Composer Custom Component
Now that you have seen the SMS Composer component in action, let's go back to the beginning and create this application. To create the application, do the following:- Create the SMSComposerExample project
- Add Packages and a Visual MIDlet to the Project
- Add Components to the Project
- Add Commands to the Project
- Connect the Components to Create an Application Flow
- Modify Task for Wait Screen
- Run the Project
Creating the SMSComposerExample Project
- Choose File > New Project (Ctrl-Shift-N). Under Categories, select JavaME. Under Projects, select Mobile Application and click Next.
- Enter
SMSComposerExample
in the Project Name field. Change the Project Location to a directory on your system. From now on let's refer to this directory as$PROJECTHOME
. - Uncheck the Create Hello MIDlet checkbox. Click Next.
- Leave the Sun Java Wireless Toolkit as the selected Emulator Platform. Click Next.
- Click Finish.
Note: The project folder contains all of your sources and project metadata, such as the project Ant script.
Adding Packages and a Visual MIDlet to the Project
- Choose the
SMSComposerExample
project in the Project Window, then choose File > New File (Ctrl-N). Under Categories, select Java. Under File Types, select Java Package. Click Next. - Enter
smscomposerexample
in the Package Name field. Click Finish. - Choose the
smscomposerexample
package in the Project window, then choose File > New File (Ctrl-N). Under Categories, select MIDP. Under File Types, select Visual MIDlet. Click Next. - Enter
SMSComposerExample
into MIDlet Name and MIDP Class Name fields. Click Finish.
The application displays in the Flow Design window of the Visual Mobile Designer.

Adding Components to the Project
- In the Flow Designer window, drag and drop the following components from the Component Palette:
- Splash Screen
- SMS Composer
- Wait Screen
- Alert (x2)
- Click on splashScreen and, in the Properties Window, change value of property Text from null to the SMS Composer Example and press Enter.
- Click on alert and, in the Properties Window, change value of property Title from alert to the alertSent, the same way change alert1 Title property from alert1 to the alertError.
- Click on alert and, in the Properties Window, change value of property String to the Message Sent, the same way change property String in the component alertError to the Error.
- Click on smsComposer and, in the Properties Window, uncheck the Automatically Send property in the SMS Properties category.
Adding Commands to the Project
- Open the Flow Designer.
- Choose Exit Command from the Commands section of the Component Palette. Drag and drop it into the smsComposer component in the Flow Designer.
Connecting Components to Create an Application Flow
In the Flow Designer, click on the Start Point on the Mobile Device and drag it to the spalshScreen component. In the same manner, connect the components together as shown in the following graphic.
Modifying Task for Wait Screen
In the Resources category of the Navigator, find and right-click the task component, choose Go To Source from the popup menu. In the Source window, find section// write task-execution user code here"
and replace it with smsComposer.sendSMS();
. Running the Project
PressJavadoc for the SMS Composer Component
The NetBeans IDE provides API Javadocs for the SMSComposer component, as well as other components you can use in the VMD. To read the Javadocs for the SMSComposer component:- Place the cursor on the SMSComposer component in the source code and press Ctr-Shift-Space (or choose Source > Show Documentation).
The Javadoc for this element displays in a popup window. - Click the Show documentation in external web browser icon (
) in the popup window to view the detailed information about the SMSComposer component in your browser.