The LightWeight User Interface Toolkit library (LWUIT) is inspired by Swing but designed for constrained devices such as mobile phones and set top boxes. LWUIT supports pluggable theme-ability, {@link com.sun.lwuit.Component}/{@link com.sun.lwuit.Container} hierarchy and abstraction of underlying GUI toolkit.
Interfaces and API's of the underlying profile are abstracted by internal toolkit interfaces and abstract classes. This allows portability and a migration path for both current and future devices and profiles. E.g. the graphics object of the underlying profile would be encapsulated by {@link com.sun.lwuit.Graphics}.
The toolkit tries to avoid the "lowest common denominator" mentality by implementing some missing features in the lower end platforms and taking better advantage of higher end platforms.
Partial class diagram:
Following is a simple hello world example written on top of MIDP, all the LWUITcode is 100% binary compatible to other platforms such as CDC. However, this example is specific for MIDP for AMS requirements a MIDlet class must exist for MIDP where in a CDC environment an Xlet would be expected (in Java SE we would expect a main class etc...).
public class HiMidlet extends MIDlet { public void startApp() { Display.init(this); Form f = new Form(); f.setTitle("Hello World"); f.setLayout(new BorderLayout()); f.add("Center", new Label("Hello Label")); f.show(); } public void pauseApp() { } public void destroyApp(boolean unconditional) { } }
Notice in the example above that the very first line of code for any application using this toolkit must register the main class with the display. This behavior is toolkit specific since in MIDP there is not much you can do without a reference to the parent MIDlet this operation must be performed in the beginning of the application.
The rest of the code is left within the MIDlet for simplicity but could be separated to any class whatsoever to allow full portability to any future platform to which the LWUIT library would be ported.
For current up to date information about LWUIT please visit the blog and the web site. For help you can turn to the forum here.