Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

Java ME User Interfaces: Do It with LWUIT! : Page 4

Java ME user interfaces are about to get an exciting boost with the early release of a new library and tool from Sun called LWUIT.


advertisement

Significant Features
While a complete examination of the LWUIT features and API is beyond the scope of this article, the list of significant features below should help wet your appetite and leave you feeling that Java ME user interfaces can rival those of the Swing or rich internet applications.

Figure 6. LWUIT GUI Component Hierarchy: As in Swing/AWT, the base class of all widgets in Component (from the com.sun.lwuit package).

Swing-Like Widget Set
Inspired by Swing, LWUIT offers a rich set of graphical user interface components that will be familiar to Swing/AWT developers. Just like in Swing, the root class of graphically displayed widgets like lists, combo boxes (selection widget), text areas, buttons, radio buttons and check boxes is Component (see Figure 6).

Also like Swing/AWT, LWUIT utilizes the composite pattern to allow nesting of components. A Container object is a Component that contains other Component objects. The container allows layout properties to be applied to the collection of Components independent of the rest of the display.



Many of the common "widgets" (text box, button, and so on.) are demonstrated in Listing 1 above. The real strength and power of LWUIT comes in how much more control you have of layout and display characteristics (color, font, and so on) of these widgets (all covered later). However, there are some differences in the actual components themselves. In order to highlight a couple of the differences between LWUIT and MIDP's LCDUI, explore these examples.

  1. Lists with Real Objects: A List widget is available in LCDUI. However, the choices in a LCDUI List are Strings and images. This makes adding a collection of records to the list for display difficult (see Listing 2) and makes associating the selected choice back to the original element in the collection even more difficult.

    Using LWUIT, a List can be handed an array or Vector of Objects (see Listing 3). Getting the selected object is as easy as calling on the getSelectedItem() method on the LWUIT List object. Figure 7 shows a comparison of MIDP's LDCUI List and LWUIT's List. Both accomplish the mission of displaying a list of data, but getting the data in an out of the LDCUI's List requires a great deal of String manipulation. LWUIT's List works with a collection of objects to get and set the list model.


    Figure 7. MIDP's LDCUI List vs. LWUIT's List: Getting the data in an out of the LDCUI's List requires a great deal of String manipulation. LWUIT's List works with a collection of objects to get and set the list model.
     
    Figure 8. LWUIT's TabbedPane: Users can pick between student info and the student picture displays here. The look and feel is of a multiple dimensional or "page" user interface that typifies desktop applications.

     

  2. The TabbedPane:: Given the tight real estate on many handheld mobile device screens, the ability to break up the display into multiple "pages" is usually a necessity. The TabbedPane serves as a container that allows the users to see the pages of the display in a tabbed notebook. Figure 8 shows how TabbedPane allows the user to pick between student info and the student picture displays, gives users the look and feel of multiple dimensional or "page" user interface that typifies desktop applications. Nothing like this exists in MIDP's LCDUI short of developers building it themselves with the low-level API.


Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap