Do-it-yourself custom GUI for a range of MIDP devices

Suppose you’re writing a game or application, and you’d like it to have an attractive, professional-looking GUI (with your theme, brand, or skin), and you’d like it to run on as many Java ME MIDP devices as possible.  There’s some work to be done, but it’s not that hard.  I wrote about how to do it in the last chapter of my book, and it was the topic of my Jazoon talk.  Plus I wrote a library of utilities to simplify the task (the Frog-Parrot UI Library), but — looking over my blog the other day — it hit me that I never really posted a technical explanation of how to use this library.

Here’s the general idea:

If you want a mature product for MIDP customization — one that will teach you how MIDP customization works as you’re using it — J2ME Polish is a good place to start, as I explained here.  But in practice, I found that I wanted 100% control over the look-and-feel of the GUI, which I couldn’t get from J2ME Polish.

Essentially, handsets have a list of standard screen sizes, and many of them are so small that I need to have pixel-by-pixel control over where everything is placed.  Having the device place the widgets, etc., for you — guessing where you want them based on layout algorithms — isn’t nearly as useful on a small screen as it is on, say, a big browser window on a P.C.  So I wrote a library that would allow me to bundle the screen information into resource files, selecting the right image files for each screen size and passing along the data for how big widgets and images are and where they should be placed.

The annoying thing about making a custom GUI for MIDP is that you have to start from scratch, drawing your GUI onto a blank canvas.  That means re-inventing the wheel on some very standard functionality: widget navigation, navigating back and forth through a stack of screens, scrolling, and even cutting up a paragraph of text in the right places so it won’t disappear off the edge of the page.  That’s the functionality I’ve written for you in the FPUIL (which you can use however you like, as long as you don’t imagine it comes with a warranty. 😉 ).

In this brand-new version (which I just re-worked today on a Windows machine, download here), I’ve included some build files to build the project with Ant and Antenna. Look at the build.xml and build_all.xml files to see some examples and explanation of how to build a MIDlet for different target devices.

That should be enough to get started, and if I find some time, I’ll try to write more explanation…


12 comments so far

  1. Pat on

    Alright, so I can’t remember where I posted last time, but I figured posting here should do. I’m working on a really cool project in JavaME and I have been using your book to help guide me along as I am not as familiar with this language compared to others. I am attempting to use a MIDI for some background music, but I don’t feel your book is extremely clear on that subject and I can’t really find any good resources online either. Can you give me a hint? I’m assuming that it will need to be in its own Thread and such, but I really am at a loss. I’m used to programming with VB and DirectX which makes everything so much less complicated, I am getting really confused with the use of Threads and everything else, and I honestly just don’t know what I need to do. If you could help I really would appreciate it. Thanks

  2. Marinkina on

    Нет,по настоящиму улыбнул 8 пункт,просто представил такую ситуацию ))).

  3. Gavrilin on

    Пора переименовать блог, присвоив название связанное с доменами 🙂 может хватит про них?

  4. Ferinannnd on

    Красавчег! Пиши исчё!

  5. carolhamer on

    Hi Pat,

    Sorry I haven’t been replying quickly to the comments on this blog.

    I’d like to help, but your question isn’t very specific. Did you try the example program that played background music from a file? Did it not work?

    Everyone else — please comment in English so that I can tell whether your comment is relevant or whether it’s spam…

  6. Mario Zorz on

    Hi Carol,

    I developed an XML driven mobile application engine. It’s open source (, the idea is that non-developers (or lazy developers like me ;)) can write applications without delving into the problems of device fragmentation or java at all.

    I haven’t gone through your FPUIL libray yet, but there’s also Mobile Windows Toolkit which pretty much offers a set of primitives for windowing and there’s a more advanced project from Sun named LWUIT (lightweight UI toolkit) which provides some quite fancy utilities for professional looking interfaces. As a matter of fact one of the milestones in Prosciutto is to integrate with LWUIT so people can just define things on XML and, again, no need to tinker with java or the internals of LWUIT at all.

    Just my 50 cents! 🙂

    Thanks a lot for your work
    Keep it up

  7. anonymous on

    It’s a shame J2ME developers have to resort to developing their own interfaces. But at least we have a few choices when it comes to libraries.

    The most well-known ones have already been mentioned here, but you can also check out J2ME GUI, which you can find at It will feel familiar to those who have developed in VB and C#. You can find a free and commercial version there.

  8. carolhamer on

    Mario — your Prosciutto Project looks very interesting. I might try it out at some point, but for the moment I’ve been just playing with BlackBerry, and they’ve got all of the widgets, etc., built into their proprietary API.

    Anonymous — I’d be happy to have a look at your solution as well, but your link doesn’t work.

  9. anonymous on

    carolhamer – Just tested that link I posted and is working. Maybe it was just down for maintenance or something? But I see the link posted by Mario doesn’t work, because there’s an extra bracket in the URL. Maybe you just confused the two?

    Thanks for your reply.

  10. carolhamer on

    No, I figured out Mario’s broken link. Your site must have been down when I tried it earlier, but I see it now.

    Looks very interesting! That’s cool that you’re shooting for the low-end devices. It’s often more fun to play with the smartphones, but for lots of applications it’s far more important to be able to run on the masses of low-end devices. It’s particularly important for promotional applications (that are tied in with an external product or service).

  11. Rengenx on

    Потыкаю по рекламке в качестве благодарности за статью!

  12. areef on

    Hi carol i have downloaded Fpuil. i am using netbeans ide so please can u guide me how to use this url and i need some examples..

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: