A Simple MIDP Application using Netbeans

The last post was on setting up the Nokia S60 SDK with netbeans 5.0. The application we are going to develop now doesn’t require the Nokia SDK. It is required only when you want to implement Nokia specific features. By the way, MIDP is called Mobile Information Device Profile. Two common versions of MIDP supported by most mobile phones across manufacturers are MIDP 1.0 and MIDP 2.0. MIDP on combination with CLDC – Connected Limited Device Configuration – allows us to build device independent applications. Both of them are products from Sun Microsystems. You can read more about MIDP here and CLDC here. Look at the huge list of mobile phones that support MIDP and CLDC.

For this application, we will use the standard emulator that ships with the netbeans mobility pack. We will create a simple application that accepts username and password. If the username is “aswin” ;) then it will take you to the next screen. Otherwise, it will display a small error box. Understood??

Ok, be a good student and fire up Netbeans 5.0.

1. Go to File–>New Project. Select “Mobile” on the left pane and “Mobile Application” on the right pane.
2. Click “Next” and give the project name as “MyGreatMobile”. Click “Next”.
3. Select the Emulator Platform as J2ME Wireless Toolkit 2.2. Leave the other settings as it is and select “Finish”.

You should have something similar to the one shown below.
1.0 A Simple MIDP Application using Netbeans

4. Choose Window–>Palette. The Palette window is now displayed. From the “Form Items” section, drag and drop 2 textfields on the “HelloForm”. The whole window should look like the one shown.
2.0 A Simple MIDP Application using Netbeans

5. From the “Commands” section of the Palette, drag-n-drop and “Ok Command” and a “Exit Command”. Press F5 at anytime to view the output on the emulator.

3.0 A Simple MIDP Application using Netbeans

6. Drag-n-drop a “List” and an “Alert” from the “Screens” section of the Palette. Link the “Ok” of “helloForm” to “list1″. We will link the Alert programmatically. Also d-n-d a few listitems from the “Elements” section and a “Ok Command” onto “list1″. Link the “Ok” of list1 to Form1. Check the screen shot below.
4.1 A Simple MIDP Application using Netbeans

7. Double click on alert1 and change the text to “Invalid username or password”.
8. Now, if you switch to the Source view from the Flow Design view, you will be able to see that all the necessary code is generated, to implement the functionality shown in the flow design. THAT IS AMAZING!

Let us switch to Source view and do some tweaking to get the functionality we want. Find the function called public void commandAction. That function implements all the necessary conditions for navigation. It initially looks like below.
5 A Simple MIDP Application using Netbeans

Change the code so that it is similar to the next screen shot.
6 A Simple MIDP Application using Netbeans

We are done. Press F5 to view the beauty :D
7 A Simple MIDP Application using Netbeans8 A Simple MIDP Application using Netbeans9 A Simple MIDP Application using Netbeans10 A Simple MIDP Application using Netbeans11 A Simple MIDP Application using Netbeans

The next post will be on consuming .net web services on Java ME. Bye!!

Related posts:

  1. Nokia S60 Emulator Integration with Netbeans 5.0
  2. Two Minute Web Browser in Java
  3. Test Yahoo Beta with out invite
  4. Google Hacking: Ten Simple Security Searches That Work
  5. FilmLoop – Photo-casting
Tags: 
Subscribe to Comments RSS Feed in this post

9 Responses

  1. Cool guys.. write more such stuffs..hoping to get more techie stuff frm here..

  2. thanks dude, will surely be posting more.

  3. hey ashwin.. great man keep it up! even i am working on J2me for my Final sem Proj.. using Eclipse and some plugins with jsr-82, Atinava..

  4. @ranganath:
    cool man :D may i know what your project is about?

  5. Wait a min… Just saw that line: Press F5!

    Haha! So, VB actually won ?:D

  6. @yuvi:
    im not conducting a competition between java and .net :-)

  7. :) ) That’s VB: It’ll win even if there’s no competietion:D

    Anyway, when’s the next post comin up dude? I can hear somebody screaming WordPress Templates and httpd.config..

  8. lol… the post was ready long time back. I’m yet to push that and publish it. Will do it in a day or two.–>

  9. Hey thanks man. simple and amazing. Keep on adding more posts. Really appreciate it.

Leave a Reply

Your email address will not be published. Required fields are marked *

*
*

Get Adobe Flash playerPlugin by wpburn.com wordpress themes