You are previewing LWUIT 1.1 for Java ME Developers.
O'Reilly logo
LWUIT 1.1 for Java ME Developers

Book Description

Create great user interfaces for mobile devices

  • Make your applications stand out with dazzling graphics that look and behave the same on different mobile devices

  • Log information on the runtime behavior of your program

  • Write applications with attractive visual effects like transitions and animations

  • Use localization so that your applications can adapt to different languages and locales

In Detail

Writing appealing cross-device applications today in Java ME is challenging as implementation differences in fonts, layout, and menus can make your application look and behave very differently on different devices. So far, the only way out has been low-level programming with its associated complexity.

The Lightweight UI Toolkit (LWUIT), an open source Java library, offers Java ME developers an easy-to-use API for creating impressive user interfaces with a device-independent look and feel. The LWUIT library contains many components and tools for bringing consistency and visual gloss to the user interface of your applications, and this book will take you through all of this, to help you get the user interfaces you want.

Java ME allows us to write applications that are, generally speaking, portable across a wide range of small devices that support the platform. While the basic functionalities usually work well on all supported devices, the area that does pose problems for developers is the User Interface. Native implementations of javax.microedition.lcdui – the primary API for UIs in Java ME – differ so widely from one device to another that maintaining a device-independent and uniform look and feel is virtually impossible. Another problem with the javax.microedition.lcdui package is that it does not support components and capabilities that can fully satisfy present day user expectations. The Lightweight UI Toolkit is the solution to these problems. LWUIT offers a wide range of components with a device-independent look and feel for building UIs. While some of these widgets are also available under lcdui, there are a number of new ones too. These additions enable application developers to design UIs that can come very close to their desktop counterparts in terms of visual sophistication and LWUIT is not just about new components either. The API supports a whole range of new functionalities (like Theming and Transitions) too.

This book takes Java ME developers through the library, with examples showing how to use the main components and functionalities. It also goes beyond a description of what is available by showing how to extend the library by plugging in custom-built classes.

Table of Contents

  1. LWUIT 1.1 for Java ME Developers
    1. LWUIT 1.1 for Java ME Developers
    2. Credits
    3. About the Author
    4. About the Reviewers
    5. Preface
      1. What this book covers
      2. What you need for this book
      3. Who this book is for
      4. Conventions
      5. Reader feedback
      6. Customer support
        1. Downloading the example code for the book
        2. Errata
        3. Piracy
        4. Questions
    6. 1. Introduction to LWUIT
      1. Why we need the LWUIT
      2. LWUIT overview
      3. Widgets
        1. Container and Form
        2. The TabbedPane
        3. Calendar
        4. Dialog
        5. Label and Button
        6. TextArea and TextField
        7. List
        8. ComboBox
      4. The underlying support elements
        1. Resource
        2. Layout managers
        3. Style
        4. Painter
        5. UIManager
        6. LookAndFeel
      5. Functionalities
        1. Animations and transitions
        2. Themes
        3. Logging
      6. The Basic architecture
      7. LWUITImplementation—the foundation of LWUIT
      8. The Display class
      9. Summary
    7. 2. Components
      1. The LWUIT bundle
      2. Getting equipped
      3. Hello LWUIT!
        1. Creating the project
        2. The code
      4. Deploying an application
      5. The Component class
        1. Methods to handle size and location
        2. Methods for event handling
        3. Methods for rendering
          1. The painting process
        4. Miscellaneous methods
        5. Animation support for components
        6. Handling Style
      6. The Graphics class
      7. Summary
    8. 3. The Container Family
      1. The Container
        1. Creating a Container
        2. The methods of the Container class
      2. The form
        1. Creating a form
        2. Handling commands
        3. The Command class
          1. Creating a command
          2. Methods of Command class
          3. Installing a command
        4. Managing the form's appearance
          1. Setting the TitleBar's looks
        5. The Font class
          1. Creating a Font
          2. The methods of the Font class
        6. Installing a new font
          1. Setting the MenuBar's looks
          2. Setting the Form's Looks
      3. The Dialog
        1. Creating a Dialog
        2. The methods of the Dialog class
        3. Displaying a dialog
      4. The Calendar
        1. Creating a Calendar
        2. Methods of Calendar class
        3. Using a Calendar
      5. The TabbedPane
        1. Creating a TabbedPane
        2. Methods of TabbedPane class
        3. A TabbedPane in action
      6. Style for the future
      7. Summary
    9. 4. The Label Family
      1. The Border class
      2. The Label
        1. The LabelDemo example
        2. Creating a Label
        3. Methods of the Label class
        4. The LabelDemo application
      3. The Button class
        1. Creating a Button
        2. The methods of Button class
        3. The DemoButton example
      4. The CheckBox
        1. Creating a CheckBox
        2. Methods of the CheckBox class
        3. The "Languages Known" example
      5. The RadioButton and ButtonGroup
        1. The ButtonGroup class
        2. Creating a RadioButton
        3. Methods of the RadioButton class
        4. The "Reservation" Example
      6. Summary
    10. 5. List and ComboBox
      1. The list
        1. Creating a List
        2. The methods of the List class
        3. Setting up a basic list
        4. A list with custom rendering
        5. The ToDoList
      2. The ComboBox
        1. Creating a ComboBox
        2. The methods of the ComboBox class
        3. A combo box with the default renderer
        4. A combo box with a custom renderer
      3. Summary
    11. 6. TextArea and TextField
      1. The TextArea
        1. Creating a TextArea
        2. The methods of the TextArea class
        3. Putting TextArea class through its paces
      2. The TextField class
        1. Creating a TextField
        2. The methods of the TextField class
        3. Checking out TextField
      3. Summary
    12. 7. Arranging Widgets with Layout Managers
      1. Layout class
      2. The LayoutStyle class
      3. BorderLayout
      4. BoxLayout
      5. CoordinateLayout
      6. FlowLayout
      7. GridLayout
      8. GroupLayout
        1. GroupLayout.Group
        2. GroupLayout.ParallelGroup
        3. GroupLayout.SequentialGroup
      9. Summary
    13. 8. Creating a Custom Component
      1. The making of a component
        1. The TimeViewer class
        2. The TimeTeller class
          1. The Real time mode
            1. Using the Alarm function
          2. The ElapsedTime mode
        3. The TimeTellerMIDlet
      2. Enhancements
      3. Summary
    14. 9. Resources Class, Resource File and LWUIT Designer
      1. The LWUIT Designer
        1. Creating a resource file
          1. Adding an image
          2. Adding an animation
          3. Adding a font
          4. Adding a localization resource
          5. Adding a Theme
        2. Saving a resource file
      2. The Resources class
      3. The SampleResource demo
        1. The manual approach
        2. The automatic approach
      4. Summary
    15. 10. Using Themes
      1. Working with theme files
        1. Viewing a theme file
        2. Editing a theme file
        3. Populating a theme
      2. Theming custom components
      3. Manual styling versus theming
      4. Theming on the fly
      5. New version of the LWUIT Designer
      6. Summary
    16. 11. Adding Animations and Transitions
      1. Animations
        1. The Hello MIDlet
      2. Transition
        1. The Transition class
          1. CommonTransitions
          2. Transition3D
        2. Using transitions
          1. The DemoTransition application
        3. Transition for components
      3. Authoring transitions
        1. The BlindsTransition class
        2. The StepMotion class
        3. The MIDlet
      4. Summary
    17. 12. Painters
      1. The Painter interface
      2. The DemoPainter application
      3. Drawing a multi-layered background
        1. The PainterChain class
        2. The DemoPainterChain application
      4. Using a glass pane
        1. The DemoGlassPane application
        2. A GlassPane with multiple layers
      5. Summary
    18. 13. Effects and Logging— Useful Utilities
      1. Using Effects
        1. The Effects class
        2. The DemoEffects application
      2. Logging with LWUIT
        1. The Log class
        2. The DemoLogger application
      3. Customizing Log
        1. The DemoMyLog MIDlet
      4. Summary