Java Reference
In-Depth Information
Figure 9-2.
Hello Xlet
The Xlet itself is simple: implementing the
Xlet
contract, it extends
Component
, which
is a lightweight AWT class that knows how to draw when its
paint
method is invoked.
On initialization, the Xlet must do several things. First, it caches aside the context
the application management system provides to use when it wants to exit. Next, it
obtains the root container provided by the context and caches it aside; this container
defines where on the screen the Xlet is permitted to draw. Finally, it adds itself to the
context-provided root container.
By default, the Xlet's UI is not visible. Thus, when the Xlet transitions to the active
state as the application manager invokes
startXlet
, the application must make its root
container visible; this causes a repaint that shows the application interface, handled by
paint
, which performs a simple
Graphics
operation to paint the message “Hello Xlet” on
the display.