In MIDlets, Alerts
are used to notify the user of errors, exceptions or otherwise important events
by showing a popup window on top of the active MIDlet. Technically, Alert is
a Screen that displays data either for a specified time period or as long until the
user dismisses the prompt. The duration of the note is defined by getTimeout() method.
If Alert.FOREVER is returned, the Alert is
modal. Otherwise the Alert is timed.
Alert is displayed in a popup window on top of
the previously displayed screen, which remains dimmed in the background. The
popup window consists of several parts:
Title - An optional heading for the Alert.
Situated on top of the dialog.
Body - Contains the actual message. In theory, even
the body text can be left as null.
Icon - An optional graphic placed on the right side
of the Alert dialog. If this is not set, a default
graphic is used.
Progress bar - An optional Gauge object
shown at the bottom of the content area
It is possible to map Commands
to Alerts.
Source code for the example:
import javax.microedition.midlet.*; import javax.microedition.lcdui.*; public class ExampleAlert extends MIDlet { Display display = Display.getDisplay(this); public void startApp() { // Alert(title, text, icon, AlertType) Alert alert = new Alert("Info", "This is an alert for informative purposes", null, AlertType.INFO); display.setCurrent(alert); } public void pauseApp() { } public void destroyApp(boolean unconditional) { } }
For more information about S60-specific Alert features,
see Alert implementation
notes.