Activity 10.3 - Running a MIDlet example

Topic

Running demonstration MIDlets on a mobile phone emulator.

Materials

In this Activity you will use the sample MIDlets provided with NetBeans.

Instructions


  1. Before you attempt this activity, you should have installed the Wireless Toolkit. This should have happened automatically when you installed the NetBeans Software CD. You can see that the Wireless Toolkit is installed in NetBeans using the Tools menu and selecting Java Platform Manager. This should show that you have the Java Micro Edition SDK 3.0 installed as well as the Java SE JDK 1.6.

    If you have some other Wireless Toolkit installed, such as the Sun Wireless Toolkit, you may need to

  2. In NetBeans select File|New Project... and the New Project wizard will appear. Under Categories: expand Samples and then select Java ME (MIDP), as shown below.

    Screengrab of NetBeans New Project window with mobile applications displayed

  3. Click on Sun Samples - Demos and then Next>.

    The wizard should now look like this. Make sure that the Project Location: is correct. It should be C:\M257\Unit 10 if you have used the same folder structure as us.

    Screengrab of NetBeans New Project window in its final status

  4. Click Finish and the new project will appear in the Projects window. (You may need to expand it to see the packages it contains.)

    Screengrab of NetBeans Projects window

  5. As you see, NetBeans uses a special icon for mobile projects (highlighted above). Make sure that SunSamples-Demos1 is set as the main project, then select Run Main Project. Compiling the program may take some time, but after a while you will be presented with an emulation of a mobile phone.

    Screengrab of mobile phone emulator

    (You can choose different emulators in the project properties dialogue. The one above is the DefaultFxPhone1.) This has the same functionality as if the phone were real (except you cannot make calls with it of course!) You 'press' buttons by clicking on them with the mouse pointer. Alternatively you can use your computer keyboard.

    On the screen of the phone a suite of MIDlets is displayed. To launch a highlighted MIDlet you can

    You can also use the Up, Down, Left and Right arrows instead of the multi-directional keys to move around the phone's menu.

    The term soft key will be explained further in the Unit, but essentially it is a key to which a variety of actions can be associated. The text above the soft key at any given time indicates the current semantics of pressing the related soft key.

  6. the central multi-directional control and soft keys
  7. Highlight the MIDlet called Colors and run it using one of the available controls.

    This will launch a MIDlet which allows you to adjust the balance of colours on a palette and is very similar to the program studied in Unit 7. You can use the multi-directional key to switch colours (up and down) and to increase or decrease the amount of a particular colour (left or right).

    By pressing the 'soft key' associated with Exit you can return to the list of MIDlets and try another. By pressing the off button of the phone, you can close the emulation and return to the NetBeans.

Follow the same steps as those above to try out some other MIDP samples. Please feel free to investigate whichever MIDlets take your fancy!