C H A P T E R  2

Using the SDK

This chapter provides a walk through of how to run and debug a sample project. It also introduces the sample applications that are included in the release.

Before beginning, be sure you have installed and configured your development environment as described in the Installation Guide.


2.1 Running and Debugging a Sample Project

This section is a step-by-step procedure.

1. Go to the Open Project dialog.


Choose the open project dialog

a. Open the File menu.

b. Select Open Project.

Note:

You can also perform this action from the NetBeans toolbar or press the corresponding shortcut.

2. Choose a sample project to open.


Choose a sample project to open

a. Browse to ToolkitHome\apps.

b. Select FPDemo.

c. Select Open Project.

3. Open Project Properties.


Open project properties

a. Right- click on FPDemo to open the project context menu.

b. Select Properties.

4. Select the correct emulator platform and choose a device for execution.


Select correct emulator platform and choose device execution.

a. Click Platform

b. Select Sun Java(TM) Wireless Toolkit for Sprint Titan Platform 1.0, Prototype Release as the Emulator Platform.

c. Choose a device for execution from the drop-down list.

d. Click OK.

Note 1:

The names of Microsoft Device Emulator and the device depend on Toolkit configuration and your Windows Mobile device name.

Note 2:

If you don't see the device you have connected to the computer or the Microsoft Device Emulator you have configured, click Manage Emulators and click Refresh on the next screen.

5. Run the project.


Run the project.

a. Open Run menu.

b. Click Run Main Project.

Note:

You can also perform this action from the NetBeans toolbar or press the corresponding shortcut

6. The application is installed on the selected device and you can launch it there.

The following graphic shows the screen on the Titan Toolkit Emulator, Microsoft Device Emulator, and a Windows Mobile device.


App installed on Toolkit emulator, MS device emulator, Windows Mobile Device

a. Select the installed application in the list.

b. Click the Launch button.

7. You'll see the output from the application in the NetBeans output window while the application is running.


NetBeans output window

8. Exit the application.


Exit the application

Click Exit.

Note: The application is uninstalled automatically and the NetBeans window gets deactivated. You can edit the application sources and run it again.


2.2 Demo Project Debugging

This section describes how to use debugging on one of the demos.

1. Open the FPDemo project and choose a device.

FollowStep 1 through Step 4 from Section 2.1, Running and Debugging a Sample Project.

2. Set a breakpoint in the demo sources.


Set a breakpoint in the demo source.

a. Double-click CalculatorMIDlet.java to open it in the source view.

b. Go to line 131 and click on the border to set the breakpoint.

3. Start a debugging session.


Start a debugging session

a. Open Run menu

b. Click Debug Main Project

Note:

You can also perform this action from the NetBeans toolbar or press the corresponding shortcut.

4. Wait for the debugger to connect to the device.


Debugger connect to device

You'll see the "User program running" message in the Debugger Console.

Note:

This can take some time in the case of a real device.

5. Launch the application on the device.

6. Trigger the breakpoint by entering numbers into the text fields and invoking the Calc command.


Trigger the breakpoint.


breakpoint

7. Debug


Debug toolbar

You can use the Debug toolbar to step through the application code.


Local Variables

You can inspect and change the values of local variables while stepping through the code.

Note: Consult the NetBeans debugger documentation for further information.

8. Finish the debugging session.


End debugging

a. If the application is paused, click continue to resume its execution.

b. Exit the application on the device to correctly end the debugging session.


2.3 Demonstrations

Demonstration projects are stored in ToolkitHome/apps.

2.3.1 Calculator

The small game shows a 4x4 grid of tiles with one empty space. Launching the game scrambles the letters. You can use the arrow keys to rearrange the tiles into the original words. Select Menu > Options to change the difficulty or change the shuffle options.

2.3.2 Tile Puzzle

The small game shows a 4x4 grid of tiles with one empty space. Launching the game scrambles the letters. You can use the arrow keys to rearrange the tiles into the original words. Select Menu > Options to change the difficulty or change the shuffle options.


Tile Puzzle

2.3.3 Date Field

This demo shows various date and time UI components.


Date Field demo

2.3.4 Custom Item

This demo shows a custom item. Use the navigation keys to move from the fields to to the table cells. Navigate from cell to cell. To input text, Select a cell. Enter Qwerty text as prompted, and choose 2 from the Edit menu to submit your change.


Custom Item allows you to enter text in cells

2.3.5 SVG Duke

This demo loads an SVG image from a file and renders it. Looking at the demo code you can see that the image is sized on the fly to exactly fit the display area. The output is clear and sharp.


Duke svg file

2.3.6 File Browser

After launching the FileBrowser MIDlet, you see a directory listing, and you can browse through the available directories and files. By default there is one directory, root1.


File browser shows root directory

Select the directory and press the select button to enter it.


File browser shows root directory and subdirs

Using the commands in the demonstration, you can view the file or see its properties. Try selecting the file and choosing Properties or View from the menu.

2.3.7 Multimedia

In order for this demo to work properly, Apple QuickTime must be properly installed on your machine. The toolkit assumes that your QuickTime installation can be found in the default location c:\Program Files\QuickTime. If you installed it to a different location, then please make sure that you update the path to QuickTime in these two files:

We apologize for this inconvenience. It will be fixed in the next release.

The Multimedia demo offers four multimedia files to be played using the MMAPI (JSR 135) implementation:

The title screen of this demo lists all these files and you can select anyone of them using the Select command. When this command is issued, the respective media file is played. For audio files a screen with a dancing Duke comes up and in case of the video file, a video screen is displayed. It is possible to get back to the title screen using the Back command. Going back also stops the current media playback.

The following image shows the MPEG video playing.


MPEG video playing

2.3.8 CityGuide

This is a demo for JSR177. It displays a city map with landmarks. Use the Location Feed tool to simulate walking in the city. An example contains an XML file containing a sample route (citywalk.xml). Start it with:

location-feed.exe xml path-to-citywalk.xml

Once the tool is started, the map on the screen will move correspondingly.