Java Reference
In-Depth Information
notifyDestroyed : Notifies the application manager that the Xlet has entered the
destroyed state
notifyPaused : Notifies the application manager that the Xlet does not want to be
active and has entered the paused state
notifyActive : Notifies the application manager that the Xlet wants to enter the
active state
You typically use getContainer at your Xlet's initialization to obtain the container into
which your other visible components should be placed. This is how the application man-
ager shares the screen with multiple Xlets; each Xlet gets a separate containing
component in which it can render its UI.
Like a MIDlet, an Xlet must signal the runtime when it wants to change state; in turn,
the runtime honors the request, performing the state change. This is how an Xlet indi-
cates that it wants to exit; instead of calling System.exit , it invokes notifyDestroyed .
Similarly, an Xlet can indicate that it wants to enter the paused state and relinquish the
UI to other Xlets by invoking notifyPaused , or it can request resumption to the active state
by invoking notifyActive .
Writing a Simple Xlet
Writing an Xlet for the PBP is simple in the abstract: simply implement the Xlet interface,
and in the process, extend a Java AWT container such as java.awt.Component . Your actual
application resides inside this container, and you can interact with the application man-
ager through the Xlet's context given to your Xlet at initialization time.
Looking at a Simple Xlet
In Listing 9-1, you saw the skeleton for an Xlet; Listing 9-2 shows an actual functioning Xlet.
Listing 9-2. A Simple Xlet
package com.apress.rischpater.HelloXlet;
import java.awt.*;
import javax.microedition.xlet.*;
public class HelloXlet extends Component implements Xlet {
private XletContext context;
private Container rootContainer;
 
Search WWH ::




Custom Search