In J2ME, MIDP is the library that allows you to build user interfaces (among
other things) and its functionalities obviously much simpler than even AWT. 
The two classes of interest are:

  • Form, which supports structured widgets called Items (TextField,
    ChoiceGroup, etc…)
  • Canvas, the lowest-level class, where you need to paint everything

Faced with the task of building a User Interface, a J2ME developer will typically
consider the following options, in increasing order of difficulty:

  1. Use a Form with the standard Items.
  2. Use a Form with custom Items.
  3. Use a Canvas.

For obvious reasons, the standard Items are pretty crude and offer only the
simplest functionality.  On the other hand, writing a Canvas from scratch is quite challenging
and requires a lot of geometric calculations and 2D drawing.  Therefore,
option 2 presents a strong appeal, striking a good balance between the other two

Taking a look at the Item class, we see that it has three abstract methods,
one of which is paint() and the other two return size-related information. 
So far, so good, it seems simple enough.

Except that…  Sun made it impossible for you to extend Item in MIDP


Because the Item class only has package-protected constructors:

public abstract class Item {
Item(String label) { ... }
Item(String label, int num) { ... }

And a closer look at the class reveals that even the abstract methods
mentioned above are package-protected as well…  I’m not sure what genius came up with this design but more distressing
is the fact that Sun actually shipped this class, which is installed on millions
of devices as we speak. 

Interestingly, they seem to have realized their mistake because MIDP 2.0
comes with a new class, CustomItem, which exposes the carefully hidden
constructors to the outside world:

public abstract class CustomItem extends Item {
protected Item(String label) { ... }

It’s too bad that MIDP 2.0 will not be widely available on phones before at
least a couple of years…

Until then, it’s back to good-ole Canvas programming.  It feels like
1996 all over again.