You already know how to create a basic alert message from Listing 1. Alerts
are best used in informational or error messages that stay on the screen for a
short period of time and then disappear. You can control several aspects of an
alert by calling the relevant methods or using the right constructor.
A D V E R T I S E M E N T
The title must be set while creating the alert and it cannot be changed
To set the message the alert displays use, setString("Message to
display") or pass the message as part of the constructor,
Alert( "Confirm", "Are you sure?", null, null); .
Use setTimeout(int time) to set the time (in milliseconds)
for which the alert is displayed on the screen. If you pass
Alert.FOREVER as the value of time, you will show the
alert forever and make the alert a modal dialog.
There are five types of alerts defined by the class AlertType:
ALARM, CONFIRMATION, ERROR,
INFO, and WARNING. These have different looks and feels
and can have a sound played along with the alert.
Associate an image with the alert using the method setImage(Image
Set an indicator with the alert using setIndicator(Gauge gauge);