Building attractive UIs in J2ME

… is not easy. If all you are looking for is functionality, then the Swing UI component library included in J2ME distribution is probably enough. It will work, but looks really dated:

J2ME Swing UI

This was almost OK few years ago until iPhone came and changed the playing field. For all its faults, iPhone has one of the best user interfaces I have ever seen. It is slick, smooth and intuitive. With a single release Apple raised the bar several notches. Suddenly people started requiring all kinds of extras that can only be categorized as “eye candy”: 3D – animated transitions, visual feedback of on-screen selection of items and advanced real-time rendered effects such as reflections.

So what can you do if you’re developing for mobile Java? There are almost too many 3rd party UI libraries available — for a pretty comprehensive listing see Forum Nokia listing:

After browsing through most of them I realized that if I want to make the UI look exactly I want, I need to create it myself. This means I needed to:

  1. Use a full screen application (see setFullScreenMode -method of Canvas)
  2. Create a subclass of javax.microedition.lcdui.Canvas to handle ALL display drawing and user input
  3. Use java.util.Timer class in your MIDlet class to create screen transitions and other animations
  4. Use UI elements drawn in an image editor to for controls, view borders etc

This is a lot of work, but the results can be as good as you can make them. J2ME API has some limitations, especially in the lack of support for most of java.lang.math. Also performance is somewhat limited, so for any kind of 3D effects you’ll need to use pre-rendered animations or try using JSR-184 API.

The most significant limitation I encountered was the font support in Nokia E71. Essentially you have only one font style available, and the smallest size is still quite large. I ended up using pre-rendered images for all static text and only using the system font for dynamically changing text.


Developing Java applications for Nokia S60 phones

I spent some time looking for a nice stock portfolio application for my Nokia E71 phone and realized that there are none. So I decided to create my own. I’ve done Java programming before but never with J2ME so off to Forum Nokia for some documentation I go.

Here are the most important pages I needed to get my application up and running:

Nokia J2ME Applications
This official Nokia J2ME page contains links to the SDK and documentation (even if some of it is out of date).

Forum Nokia Java Development Wiki
It took me a while to realize the that the most useful and up-to-date documentation is found on this wiki and not on the “Documentation” page.

Forum Nokia Mobile Java Discussion Forum
Pretty useful discussions and the best forum for Nokia device -specific questions. Most people programming for J2ME devices (at least in the US) target phones from other manufacturers first.

Sun Java ME Technology APIs & Docs
Online documentation for the base CLDC and MIDP specifications. For most of the Nokia phones you’ll want to use CLDC 1.1 and MIDP 2.0. Newer S60 phones based on the S60 5th edition support MIDP 2.1 specification.

Some observations on the 3rd party independent developer support by Nokia:

Documentation is out of date
There is a lot of documentation, but some of it is out of date and overlapping. The available SDKs have been tested with old versions of the NetBeans and Eclipse IDE and the installation instructions are not much help with the latest versions.

Little Nokia participation on official discussion boards
Forum Nokia discussion boards contain mostly people asking questions and trying to piece together answers. There seems to be very little (if any) official Nokia presence.

Worst. Emulator. Ever.
Nokia S60 phone emulator is really bad. It is slow, unreliable and barely customizable. Use the Sun WTK emulator as much as you can and test on the device.