Java Reference
In-Depth Information
Listing 9-1. The Simplest of Xlets
import javax.microedition.xlet.*;
public class SimplestXlet implements Xlet {
public SimplestXlet () {
}
public void destroyXlet( boolean unconditional )
throws XletStateChangeException {
}
public void initXlet( XletContext context )
throws XletStateChangeException {
}
public void pauseXlet() {
}
public void startXlet() throws XletStateChangeException {
}
}
This Xlet obviously doesn't do anything, but it illustrates an important point: it shows
that that the Xlet interface implementation can also throw the XletStateChangeException .
This exception indicates that a particular state transition has failed—for example, from
loaded to initialized, or from running to paused, or the reverse. How the application
management system handles these exceptions depends on the failed state transition and
the implementation of the platform.
Using the Xlet Context
For each Xlet, the application manager associates a context, which is an instance of
javax.microedition.xlet.XletContext . The runtime provides this manager so that the
Xlet can interact with its environment. The XletContext interface provides the following
methods:
getClassLoader : Returns the base class loader of the Xlet
getContainer : Returns the root container into which an Xlet should place its
components
getXletProperty : Returns a named property from the XletContext
 
Search WWH ::




Custom Search