
Developer’s Guide
VERSION 3.01
Borland Software Corporation
100 Enterprise Way, Scotts Valley, CA 95066-3249
www.borland.com
Borland
®
JBuilder
™
MobileSet

Refer to the file mobileset_deploy.txt for a complete list of files that you can distribute in accordance with the JBuilder
MobileSet License Statement and Limited Warranty.
Borland Software Corporation may have patents and/or pending patent applications covering subject matter in this
document. Please refer to the product CD or the About dialog box for the list of applicable patents. The furnishing of
this document does not give you any license to these patents.
COPYRIGHT © 1997–2002 Borland Software Corporation. All rights reserved. All Borland brand and product names
are trademarks or registered trademarks of Borland Software Corporation in the United States and other countries.
All other marks are the property of their respective owners.
For third-party conditions and disclaimers, see the Release Notes on your JBuilder product CD.
Printed in the U.S.A.
JBME301DG 4E4R0802
0203040506-9 8 7654321
PDF

i
Copyright © 2002, Borland Software Corporation. All rights reserved. BORLAND CONFIDENTIAL
June 18, 2002 9:47 am (K:\IPG\MiniMe3\pubs-production\pdf\devgd\dgTOC.fm)
Chapter 1
Introduction 1-1
Contents. . . . . . . . . . . . . . . . . . . . . . . 1-1
Resource links . . . . . . . . . . . . . . . . . . . 1-3
Documentation conventions . . . . . . . . . . . 1-4
Chapter 2
What’s new in MobileSet 3.01 2-1
Vendor device support . . . . . . . . . . . . . . 2-1
Installation updates . . . . . . . . . . . . . . . . 2-2
Unified Emulator Interface (UEI) support . . . 2-2
MIDP Screen Manager . . . . . . . . . . . . . . 2-3
Class file obfuscation . . . . . . . . . . . . . . . 2-4
Chapter 3
The MobileSet development
environment 3-1
Overview . . . . . . . . . . . . . . . . . . . . . . 3-1
Setting up a JDK . . . . . . . . . . . . . . . . . . 3-2
JBuilder SE and Enterprise . . . . . . . . . . 3-2
Adding a J2ME MIDP/CLDC JDK . . . . 3-2
Specifying a MIDP/CLDC JDK for
a new project. . . . . . . . . . . . . . . . 3-5
Specifying a MIDP/CLDC JDK for
an existing project. . . . . . . . . . . . . 3-5
Specifying a default MIDP/CLDC
JDK for all projects . . . . . . . . . . . . 3-6
JBuilder Personal . . . . . . . . . . . . . . . . 3-6
Specifying a device for the emulator . . . . . 3-6
Designing a MIDP UI . . . . . . . . . . . . . . . 3-8
Compiling, running, and debugging a
MIDP application . . . . . . . . . . . . . . . .3-10
Using the Screen Manager . . . . . . . . . . . . 3-11
Obfuscating MIDlet class files . . . . . . . . . . 3-13
Configuring an obfuscator . . . . . . . . . . 3-14
Obfuscating the files . . . . . . . . . . . . . .3-16
Setting up JBuilder for J2ME Palm
Application development . . . . . . . . . . . .3-17
Chapter 4
Creating and managing MIDP
projects 4-1
Creating a new project with the Project
Wizard . . . . . . . . . . . . . . . . . . . . . . . 4-1
Adding the MIDlet files to the project . . . . . . 4-5
Setting MIDP project properties. . . . . . . . . . 4-5
Runtime configurations. . . . . . . . . . . . . 4-6
Main class. . . . . . . . . . . . . . . . . . . 4-7
JAD file . . . . . . . . . . . . . . . . . . . . 4-7
OTA URL . . . . . . . . . . . . . . . . . . . 4-8
VM parameters. . . . . . . . . . . . . . . . 4-8
Emulator parameters . . . . . . . . . . . . 4-8
Emulator device . . . . . . . . . . . . . . . 4-8
MIDlet parameters. . . . . . . . . . . . . . 4-8
Build target . . . . . . . . . . . . . . . . . . 4-9
Chapter 5
Building MIDP applications 5-1
Compiling . . . . . . . . . . . . . . . . . . . . . . 5-1
Types of compiling . . . . . . . . . . . . . . . 5-1
What can be compiled . . . . . . . . . . . . . 5-2
Running . . . . . . . . . . . . . . . . . . . . . . . 5-2
Running MIDlets . . . . . . . . . . . . . . . . 5-2
Running from the MIDlet file(s) . . . . . . 5-2
Running from a JAD file . . . . . . . . . . 5-3
Selecting which device to use. . . . . . . . 5-5
Debugging . . . . . . . . . . . . . . . . . . . . . . 5-5
MIDlet debugging in JBuilder . . . . . . . . . 5-5
Debugger limitations . . . . . . . . . . . . . . 5-6
Chapter 6
Creating a MIDP user interface 6-1
Overview . . . . . . . . . . . . . . . . . . . . . . 6-1
MIDP Screens . . . . . . . . . . . . . . . . . . . . 6-1
MIDP UI components . . . . . . . . . . . . . . . 6-3
MIDP UI class hierarchy . . . . . . . . . . . . . . 6-5
Creating a UI . . . . . . . . . . . . . . . . . . . . 6-5
Creating a project . . . . . . . . . . . . . . . . 6-6
Creating the MIDlet and Displayable
classes. . . . . . . . . . . . . . . . . . . . . . 6-7
Using the MIDP Designer . . . . . . . . . . . . . 6-9
Requirements for a MIDP class to
be designable. . . . . . . . . . . . . . . . . . 6-9
Opening the MIDP designer. . . . . . . . . . . 6-10
Adding components to the design . . . . . 6-11
Moving components . . . . . . . . . . . . . 6-12
Deleting components . . . . . . . . . . . . . 6-12
Copying components . . . . . . . . . . . . . 6-13
Undoing and redoing an action . . . . . . . 6-13
Setting properties in the inspector. . . . . . 6-13
Creating a Canvas . . . . . . . . . . . . . . . 6-13
Contents

ii
Copyright © 2002, Borland Software Corporation. All rights reserved. BORLAND CONFIDENTIAL
June 18, 2002 9:47 am (K:\IPG\MiniMe3\pubs-production\pdf\devgd\dgTOC.fm)
Creating a Ticker . . . . . . . . . . . . . . . .6-15
MIDP events . . . . . . . . . . . . . . . . . . . .6-16
Overview . . . . . . . . . . . . . . . . . . . .6-16
Generating MIDP event-handling
code. . . . . . . . . . . . . . . . . . . . .6-17
Using images with MIDlets. . . . . . . . . . . .6-17
Adding PNG images to a MIDlet
Displayable . . . . . . . . . . . . . . . . . . 6-17
Specifying an image to represent
the MIDlet Suite . . . . . . . . . . . . . . .6-18
Specifying images to represent
MIDlets within a MIDlet Suite . . . . . . .6-18
Customizing the component palette . . . . . . .6-19
Component initialization . . . . . . . . . . . . .6-19
Viewing class reference documentation
for MIDP classes . . . . . . . . . . . . . . . . .6-20
Chapter 7
MIDP database programming 7-1
Overview . . . . . . . . . . . . . . . . . . . . . . 7-1
Using RMS . . . . . . . . . . . . . . . . . . . . . 7-1
Chapter 8
Archiving MIDlets 8-1
Archiving MIDlets from the command line. . . 8-2
Creating the manifest file . . . . . . . . . . . 8-2
MIDlet manifest attributes. . . . . . . . . 8-3
Creating the JAR file outside of JBuilder. . . 8-4
Creating the JAD file outside of JBuilder . . 8-5
JAD file attributes. . . . . . . . . . . . . . 8-6
Archiving MIDlets with the Archive
Builder. . . . . . . . . . . . . . . . . . . . . . . 8-7
JAR file contents . . . . . . . . . . . . . . . .8-15
Obfuscated class files. . . . . . . . . . . .8-15
JAD file contents . . . . . . . . . . . . . . . .8-16
Archiving MIDlets with the Nokia
Developer’s Suite for J2ME
™ . . . . . . . . . . . . . 8-17
Chapter 9
Over The Air (OTA) Provisioning 9-1
What is OTA Provisioning? . . . . . . . . . . . . 9-1
What’s involved in OTA Provisioning? . . . . . 9-2
Configuring the server for JAD and
JAR MIME types . . . . . . . . . . . . . . . . . 9-3
OTA Provisioning in MobileSet . . . . . . . . . 9-4
Uploading your MIDlet Suite to a server . . 9-4
Downloading MIDlet Suites from
the server . . . . . . . . . . . . . . . . . . . 9-6
Running an installed MIDlet Suite . . . . . . 9-8
Running a MIDlet Suite directly from
a server . . . . . . . . . . . . . . . . . . . . . 9-8
Resources on OTA Provisioning. . . . . . . . . 9-10
Chapter 10
JBuilder MobileSet Samples 10-1
Running MIDP samples in JBuilder. . . . . . . 10-1
Running from the MIDlet file . . . . . . . . 10-1
Running from a JAD file . . . . . . . . . . . 10-2
Using the emulator . . . . . . . . . . . . . . 10-3
Samples delivered with MobileSet . . . . . . . 10-3
Hello World . . . . . . . . . . . . . . . . . . 10-3
MIDP UI Demo . . . . . . . . . . . . . . . . 10-3
Stock Tracker. . . . . . . . . . . . . . . . . . 10-4
Stop Watch . . . . . . . . . . . . . . . . . . . 10-5
MobileBookStore . . . . . . . . . . . . . . . 10-5
Overview . . . . . . . . . . . . . . . . . . 10-5
Description . . . . . . . . . . . . . . . . . 10-5
Running the MobileBookStore sample . 10-6
Appendix A
Tutorial: Creating and testing
MIDlets A-1
Creating a project . . . . . . . . . . . . . . . . . A-2
Creating MIDlet1 . . . . . . . . . . . . . . . . . A-4
Designing the UI for MIDlet1 . . . . . . . . . . A-7
Adding a StringItem . . . . . . . . . . . . . A-9
Adding a DateField . . . . . . . . . . . . . . A-12
Adding a Ticker . . . . . . . . . . . . . . . . A-13
Compiling and saving the project. . . . . . . . A-15
Testing MIDlet1 . . . . . . . . . . . . . . . . . . A-16
Adding additional MIDlets . . . . . . . . . . . A-17
Designing the UI for the new MIDlets . . . . . A-17
Adding an image to the project . . . . . . . A-17
Putting the image in Displayable2. . . . . . A-18
Adding a gauge to Displayable3. . . . . . . A-19
Testing all three MIDlets . . . . . . . . . . . . . A-19
Archiving the MIDlet Suite . . . . . . . . . . . A-20
Running from the JAD file . . . . . . . . . . . . A-22
Using Micro-Run . . . . . . . . . . . . . . . A-22
Specifying the default file to run. . . . . . . A-22
Appendix B
Tutorial: StopWatch MIDlet B-1
Overview . . . . . . . . . . . . . . . . . . . . . .B-1
Part 1: Creating the project and core
MIDlet files . . . . . . . . . . . . . . . . . . . .B-3
Step 1: Creating a project for the MIDlet . . . B-3

iii
Copyright © 2002, Borland Software Corporation. All rights reserved. BORLAND CONFIDENTIAL
June 18, 2002 9:47 am (K:\IPG\MiniMe3\pubs-production\pdf\devgd\dgTOC.fm)
Step 2: Creating the MIDlet files . . . . . . . B-4
Part 2: Creating the MainMenu functionality. . B-6
Step 1: Adding the MainMenu class
constants. . . . . . . . . . . . . . . . . . . . B-7
Step 2: Adding the MainMenu instance
variables . . . . . . . . . . . . . . . . . . . . B-7
Step 3: Modifying the super() call to
use new list items. . . . . . . . . . . . . . . B-7
Step 4: Adding event handling to
commandAction() method . . . . . . . . . B-8
Step 5: Creating a destroy() method . . . . . B-9
Part 3: Creating the basic stopwatch
functionality . . . . . . . . . . . . . . . . . . . B-9
Step 1: Creating a new Displayable. . . . . . B-9
Step 2: Importing additional classes . . . . .B-10
Step 3: Creating the instance variables . . . .B-10
Step 4: Changing the constructor . . . . . . .B-11
Step 5: Initializing the stopwatch
commands . . . . . . . . . . . . . . . . . . .B-11
Step 6: Handling the stopwatch
commands . . . . . . . . . . . . . . . . . . .B-12
Step 7: Creating a destroy() method . . . . .B-14
Step 8: Creating the TimerTask . . . . . . . .B-15
Part 4: Painting the time on the Canvas . . . . .B-15
Step 1: Clearing the Canvas . . . . . . . . . .B-16
Step 2: Finding out the current time . . . . .B-16
Step 3: Changing the pen color . . . . . . . .B-16
Step 4: Specifying the font . . . . . . . . . . .B-16
Step 5: Drawing the current time . . . . . . .B-17
Part 5: Formatting the time . . . . . . . . . . . .B-17
Step 1: Creating the formatTime()
method. . . . . . . . . . . . . . . . . . . . .B-17
Step 2: Checking how many seconds. . . . .B-18
Step 3: Creating strings for minutes
and seconds . . . . . . . . . . . . . . . . . .B-18
Step 4: Creating the final time. . . . . . . . .B-18
Step 5: Initializing the font at the
largest possible size . . . . . . . . . . . . . B-19
Step 6: Compiling and running the
MIDlet . . . . . . . . . . . . . . . . . . . . B-20
Part 6: Creating the StopWatch options. . . . . B-20
Step 1: Creating the Options
Displayable. . . . . . . . . . . . . . . . . . B-20
Step 2: Adding Class Constants . . . . . . . B-21
Step 3: Creating the Instance Variables . . . B-21
Step 4: Modifying the constructor . . . . . . B-22
Step 5: Adding OK and Cancel to
the jbInit() . . . . . . . . . . . . . . . . . . B-22
Step 6: Adding OK and Cancel
command handling . . . . . . . . . . . . . B-23
Step 7: Creating getter and setter
methods for the time format . . . . . . . . B-23
Step 8: Adding support for Options in
MainMenu . . . . . . . . . . . . . . . . . . B-24
Part 7: Changing the time display based
on the option. . . . . . . . . . . . . . . . . . . B-25
Part 8: Writing options to/from RMS
record store . . . . . . . . . . . . . . . . . . . B-25
Step 1: Importing the RMS package . . . . . B-26
Step 2: Defining the database name . . . . . B-26
Step 3: Changing the display variable
name . . . . . . . . . . . . . . . . . . . . . B-26
Step 4: Creating the loadOptions()
method . . . . . . . . . . . . . . . . . . . . B-26
Step 5: Creating the saveOptions()
method . . . . . . . . . . . . . . . . . . . . B-28
Step 6: Loading saved user options
on startup. . . . . . . . . . . . . . . . . . . B-29
Step 7: Saving user options before
quitting . . . . . . . . . . . . . . . . . . . . B-29
Step 8: Saving and testing the MIDlet. . . . B-29
Index I-1