Java Reference
In-Depth Information
With these modifications, your TeleTransfer MIDlet is able to handle the desired commands. You
still need to add the Command s to the Form , and register the TeleTransfer MIDlet as a
CommandListener in order to actually receive the commands:
public TeleTransfer() {
...
mainForm.addCommand (sendCommand);
mainForm.addCommand (clearCommand);
mainForm.addCommand (exitCommand);
mainForm.setCommandListener(this);
}
Figure 3.6 shows the Send Alert of the new version of your TeleTransfer application.
Figure 3.6. The TeleTransfer MIDlet showing an alert that displays the transfer
information as a summary before sending.
Further Item Classes: Gauge and DateField
Now you have used all the Item subclasses except Gauge and DateField . Both classes are
specialized input elements, where the Gauge may also make sense as a pure read-only information
item.
The Gauge item visualizes an integer value by displaying a horizontal bar. It is initialized with a label,
a flag indicating whether it is interactive, and a maximum and an initial value. If a Gauge is interactive,
the user is allowed to change the value using a device-dependent input method. Changes to the gauge
value will cause ItemEvent s if a corresponding listener is registered to the form.
The following code snippet shows the construction of a non-interactive Gauge labeled Progress that is
initialized with a value of 0 and a maximum of 100:
Gauge gauge = new Gauge ("Progress", false, 0, 100);
If a Gauge is used to display progress of a process that takes a longer amount of time, you should also
add a corresponding Stop command to the form to abort the progress.
The current value of the Gauge can be set using the method setValue() and read using the method
getValue() . Analogous setMaxValue() and getMaxValue() methods let you access the
maximum value of the Gauge .
The DateField is a specialized widget for entering date and time information in a simple way. It can
be used to enter a date, a time, or both types of information at once. The appearance of the
DateField is specified using three possible input mode constants in the constructor. Possible
DateField mode constants are listed in Table 3.6 .
Table 3.6. DateField Mode Constants
 
 
 
Search WWH ::




Custom Search