|
||||||||||
PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES |
See:
Description
Interface Summary | |
---|---|
MenuItem | Implementing classes can be used as menu choices in a Menu . |
Class Summary | |
---|---|
DeviceScreen | The DeviceScreen class is a base class for any screen that needs complete
control over how it is painted. |
Dialog | The Dialog class is a base class for any screen that accepts user input
using standard components like the text box. |
Menu | The Menu class is used for creating the application's menus. |
Theme | Derive this class to set the application's theme. |
UIManager | The UI manager orchestrates the UI for a MIDlet. |
UI framework for building professional looking applications that have a consistent experience across devices. The J4ME looks and behaves like the mobile editions of Google Maps, GMail, and the Opera Mini browser.
The J4ME UI was built in response to shortcomings of J2ME's standard LCDUI. It suffers because it looks bad, behaves differently and in an unintuitive manner on almost every phone, and is a bit cumbersome to code in because of its procedural API.
The J4ME UI uses a lot of classes found in the LCDUI package. For
example javax.microedition.lcdui.Graphics
is still used for drawing.
The easiest way to code your application is to make a class for every screen. There is a small code size penalty for this because each new class takes around 200 KB. Phones used to have many restrictions about how big the Jar file could be and you still don't want applications to be too big since they have to be downloaded to phones. But these problems are not as acute as they once were and the time savings from code simplification and clarity you gain are worth the trade off today.
The base class for all screens is DeviceScreen
. If you screen does
free drawing over an area it would derive from this class. The Etch-A-Sketch example
shows where this is useful.
DeviceScreen
defines a title bar at the top of the screen and menu
bar at the bottom. These are optional areas that can be hidden. The menu bar supports
up to two options that can be selected using the phone's menu buttons (note the extra
menu buttons found on some phones are ignored, such as the middle "Menu" button on
Motorola phones).
Dialog
screens are built using components. This is the most common
type of screen and can be assembled quickly by stringing together labels, progress
bars, pictures, text boxes, and the like. The Dialog
class houses all
the components and lays them out on the screen. It adds a scroll bar automatically
when the screen is not big enough to show all the components.
The Menu
classes are the last common type of screens. These are
just menus where the user can select from multiple options.
Components are just UI widgets that can be placed onto a screen. Common examples are
labels and text boxes. Typically components are used with the DeviceScreen
class, but that is not a requirement. Components are discussed in more detail in the
org.j4me.examples.ui.components
package.
The appearance of applications can be completely adjusted by supplying a different
Theme
class. The most common change is to use a different color scheme.
However, more complex changes can be made such as displaying background images.
The J4ME UI API is designed to be similar to the LCDUI. However, each J4ME screen is typically defined by its own class with methods that can be overridden to handle menu commands. Therefore set aside some time for porting; perhaps 15 minutes per screen.
Start your porting with the following steps. There will certainly be compile errors due to scope errors that need be cleaned up when you are done. But this should get you most of the way and illustrate the differences between the J4ME and LCDUI APIs.
startApp
method add UIManager.init(this);
as the first line
Canvas
class to DeviceScreen
Form
class to Dialog
CommandListener.commandAction
methods with overrides of declineNotify
and acceptNotify
Item
is replaced by its Component
counterpart; for example Guage
with ProgressBar
Examples are provided in the /examples
folder under the
org.j4me.examples.ui.*
packages. The examples all run under the
UIDemoMidlet
:
Dialog
screen
DeviceScreen
class directly
|
||||||||||
PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES |