Java Reference
In-Depth Information
Figure 5-3 shows the
Exit
command being mapped to one of the MIDP simulator's soft
buttons. If you add another command to this MIDlet, it will be mapped to the other soft button.
If you continue adding commands, the ones that don't fit on the screen will be put into an off-
screen menu. For example, a screen with four commands shows up in the MIDP simulator as
illustrated in Figure 5-4a.
If you press the soft button for
Menu
, you'll see the remainder of the commands as shown
in Figure 5-4b. Menu items can now be selected by pressing a number or using the arrow keys
for navigation. In the example shown in Figure 5-4, the
Exit
command is given a higher priority
(lower number) than the other commands, which ensures that it appears directly on the screen.
The other commands, with a lower priority, are relegated to the command menu.
(a)
(b)
Figure 5-4.
This MIDlet has more commands than the device has soft buttons. Invoking the
(a) system-generated Menu command brings up the (b) remaining commands.
All
Displayable
s have a title and an optional ticker. The
title
is just what you expect: a
string that appears at the top of a
Displayable
. As you saw in Figure 5-3, the title of the screen
is TextBox. Subclasses of
Screen
have constructors that set the title, but the title may also be
accessed using the following methods:
public void setTitle(String newTitle)
public String getTitle()
Tickers
A ticker is simply a bit of text that scrolls across the top of a
Displayable
; it is named after old-
fashioned stock tickers.
The
Ticker
class is a simple wrapper for a string. To add a ticker to a screen, you would do
something like this:
Search WWH ::
Custom Search