Visual Mobile Designer Custom Components: Creating a Personal Information Manager Application

The Visual Mobile Designer (VMD) is a graphical interface within NetBeans Mobility that enables you to design mobile applications using drag and drop components. The VMD allows you to define the application flow and design your GUI using the components supplied by the IDE or components you design yourself. The VMD contains many standard User Interface (UI) components that you can use to create applications such as Lists, Alerts, Forms and Images. It also includes custom components that simplify the creation of more complex features, such as Wait Screens, Splash Screens, Table Items and more.

The PIM Browser is a custom component that provides easy access to standard mobile devices functions like calendar, address book or task list. You can use the PIM Browser component to enable mobile Java applications to access locally stored personal information databases. This component utilizes The PIM (Personal Information Management) API which is a part of the JSR-75 specification's PDA Optional Packages for the Java ME Platform. Because JSR-75 is not a part of the MIDP 2.0 specification, it is by definition a custom component and can only be used with JSR-75 enabled devices.

This tutorial shows you how to use the PIM Browser component in a mobile application for JSR-75 capable devices. It demonstrates the basic features of the the component such as browsing the content of a device's contact database, Calendar or To Do List. In addition to the PIM Browser, we also need to use three other components: Splash Screen, TextBox and Alert.


Content on this page applies to NetBeans IDE 6.9 and later

To follow this tutorial, you need the software and resources listed below.

Software or Resource Version Required
NetBeans IDE with Java ME Version 6.9 and later
Java Development Kit (JDK) Version 6 and 7

If you are new to NetBeans Mobility, you should start with the NetBeans Java ME MIDP Quick Start Guide before continuing.

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 PIMBrowserExample application:

  1. Download
  2. Unzip the file.
  3. In the IDE, choose File > Open Project and browse to the folder that contains the unzipped files with the PIMBrowserExample project.
  4. Click Open Project.
    The Projects window should look like the following:
  5. Project window with PIM Browser example opened

  6. 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.
  7. In the Emulator window, click the button underneath "Launch."
    The emulator displays a Splash Screen component then PIM Browser, as shown:
  8. SDK 3.0 emulator displaying the sample PIM Browser application

  9. Click the right upper button of the emulator to display the menu items like shown below:

    SDK 3.0 emulator displaying the menu items

  10. With the Details item selected, click the central button on the emulator, to display the contact details:
  11. WTK 2.5 emulator displaying the sample PIM Browser application

  • Move the cursor up and down to navigate through available positions.
  • Click the button underneath "Back" to come back to the contact list.
  • Click the button underneath "Exit" to close the application.


Creating an Application with the PIM Browser Custom Component

Now that you have seen the PIM Browser component in action, let's go back to the beginning and create this application. To create the application, do the following:

  1. Create the PIMBrowserExample Project
  2. Add packages and a visual MIDlet to the Project
  3. Add components to the Project
  4. Add Commands to the Project
  5. Connect Components to Create an Application Flow
  6. Add Contacts to the Wireless Toolkit Contact Database
  7. Run the Project

Creating the PIMBrowserExample Project

  1. Choose File > New Project (Ctrl-Shift-N). Under Categories, select Java ME. Under Projects, select Mobile Application and click Next.
  2. Enter PIMBrowserExample 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.
  3. Uncheck the Create Hello MIDlet checkbox. Click Next.
  4. Leave the Java (TM) Platform Micro Edition SDK 3.0 as the selected Emulator Platform. Click Next.
  5. In the More Configurations Selection, click Finish.
  6. 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

  1. Choose the PIMBrowserExample project in the Project view, then choose File > New File (Ctrl-N). Under Categories, select Java. Under File Types, select Java Package. Click Next.
  2. Enter pimbrowserexample in the Package Name field. Click Finish.
  3. Choose the pimbrowserexample package in the Project view, then choose File > New File (Ctrl-N). Under Categories, select MIDP. Under File Types, select Visual MIDlet. Click Next.
  4. Enter PIMBrowserExample into MIDlet Name and MIDP Class Name fields. Click Finish.
    The application displays in the Flow view of the Visual Mobile Designer.

Adding Components to the Project

  1. In the Flow Designer, drag and drop the following components from the Component Palette:
    • Splash Screen
    • Alert
    • PIM Browser
  2. Click on splashScreen and, in the Properties Window, change the Text value from null to PIM Browser Example.
  3. Click on alert and, in the Properties Window, change the String property value to Contact selected.

Adding Commands to the Project

  1. In the Flow Designer, choose Exit Command from the Commands section of the Component Palette.
  2. Drag and drop it into the pimBrowser component.

Connecting Components to Create an Application Flow

In the Flow Designer, click on the Started on the Mobile Device and drag it to the splashScreen component. In the same manner, connect the components together as shown in the following graphic.

Shows the Flow Designer with components conneted by command lines

Adding Contacts to the Wireless Toolkit Contact Database

Copy the sample contact to the javame-sdk folder in your user directory $JAVAME-SDKHOME/3.0/work/0/appdb/PIM/contacts/Contacts/.
This folder contains the following three files by default:

  • 1.vcf
  • 2.vcf
  • categories.txt
  • Running the Project

    Press F6 to run the main project or select Run > Run Main Project.


    Javadoc for the PIM Browser Component

    The NetBeans IDE provides API Javadocs for the PIMBrowser component, as well as other components you can use in the VMD. To read the Javadocs for the PIMBrowser component do the following:

    1. Place the cursor on the PIMBrowser 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.
    2. Click the Show documentation in external web browser icon (Show documentation in external web browser) in the popup window to view the detailed information about the PIMBrowser component in your browser.


    See Also


    get support for the NetBeans