Java Reference
In-Depth Information
update the gauge whenever you read some data. A continuous gauge shows progress, probably
using an animation, with no prodding needed from the application. This type of gauge is useful
for operations where you can't measure the progress.
The gauge value itself can be set to one of the following:
•
INCREMENTAL_UPDATING
indicates that you have just accomplished something and the
gauge should be updated to reflect it.
•
INCREMENTAL_IDLE
means that you want the gauge to be incremental but nothing is
currently happening.
•
CONTINUOUS_RUNNING
indicates a continuous gauge in its running mode.
•
CONTINUOUS_IDLE
is used for a continuous gauge, indicating that no progress is currently
being made.
The following example shows interactive, continuous, and incremental gauges.
Command
s
(
Update
and
Idle
) set the appropriate values on the continuous and incremental gauges. Normally
you would set these from separate threads, but using commands makes it easy to understand
what's going on in this example.
In Sun's MIDP emulator, the continuous and idle gauges use simple Duke animations to
show progress. See Figure 6-11 for a screen shot. Listing 6-2 contains the source code for a
MIDlet that demonstrates different kinds of
Gauge
s.
Figure 6-11.
Three kinds of Gauges in MIDP 2.0
Listing 6-2.
GaugeMIDlet Source Code
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
public class GaugeMIDlet
extends MIDlet
implements CommandListener {
private Display mDisplay;
Search WWH ::
Custom Search