org.j4me.ui
Class UIManager

java.lang.Object
  extended by org.j4me.ui.UIManager

public class UIManager
extends java.lang.Object

The UI manager orchestrates the UI for a MIDlet. There is one UIManager object for the entire application and all of its methods are static. You must call the init method first.

Each screen, defined by a class derived from DeviceScreen, can be attached to the manager. The manager is responsible for navigating between screens, getting them to paint themselves, and all other UI control.

The application's appearance can be changed by providing a new theme. Create a new theme class, derived from Theme, and then attach it to the UI manager. All the different screens will take on the colors and layout defined by the new theme.

See Also:
DeviceScreen, Theme

Constructor Summary
UIManager()
           
 
Method Summary
static javax.microedition.lcdui.Display getDisplay()
          Gets the Display for this MIDlet.
static DeviceScreen getScreen()
          Returns the currently selected J4ME screen.
static Theme getTheme()
          Returns the theme used throughout the application.
static void init(javax.microedition.midlet.MIDlet midlet)
          Creates a UIManager implementation.
protected static void setScreen(DeviceScreen canvas, javax.microedition.lcdui.Displayable screen)
          Sets the current screen for the application.
static void setTheme(Theme theme)
          Sets the theme used throughout the application.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UIManager

public UIManager()
Method Detail

init

public static void init(javax.microedition.midlet.MIDlet midlet)
Creates a UIManager implementation. One of these should be created per MIDlet and be stored in the application's model.

The theme is set to the default, represented by the Theme class. To apply your own theme use the setTheme method.

Note that you should ensure your application is running on MIDP 2.0+ device. Otherwise the system will throw a runtime exception that will immediately kill your MIDlet without warning.

Parameters:
midlet - is the MIDlet class that defines this application.

getTheme

public static Theme getTheme()
Returns the theme used throughout the application. The theme controls the color schemes and fonts used by the application. It also defines the appearance of the title bar at the top of any screens and the menu bar at the bottom.

Returns:
The current theme of the application.

setTheme

public static void setTheme(Theme theme)
Sets the theme used throughout the application. The theme controls the color schemes and fonts used by the application. It also defines the appearance of the title bar at the top of any screens and the menu bar at the bottom.

Parameters:
theme - is the new theme for the application.

setScreen

protected static void setScreen(DeviceScreen canvas,
                                javax.microedition.lcdui.Displayable screen)
Sets the current screen for the application. This is used exclusively by the canvas class in this package.

Parameters:
canvas - is the J4ME object that wraps screen.
screen - is the actual LCDUI Displayable which takes over the device's screen.
See Also:
DeviceScreen.show()

getScreen

public static DeviceScreen getScreen()
Returns the currently selected J4ME screen. If no screen is set, or a non-J4ME screen is displayed, this will return null.

The application can call toString on the returned screen to get its name for logging purposes.

Returns:
The currently displayed J4ME screen or null if none is set.

getDisplay

public static javax.microedition.lcdui.Display getDisplay()
Gets the Display for this MIDlet.

Returns:
The application's Display.