|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--javax.microedition.lcdui.Displayable | +--javax.microedition.lcdui.Screen | +--javax.microedition.lcdui.Alert
An Alert is a Screen
that shows data to the user and waits for
a certain period of time before proceeding to the next Screen. An Alert
is an ordinary Screen that can contain text
(a String
) and an Image
, and
which handles events like other Screens.
The intended use of Alert is to inform the user about errors and other exceptional conditions.
The application can set the Alert's time to be infinity with
setTimeout(Alert.FOREVER)
in which case the Alert
is considered to be modal and the implementation provides a
feature that allows the user to "dismiss" the Alert, whereupon the
next Screen is displayed as if the timeout had expired immediately.
If an application specifies an Alert to be of a timed variety and gives it too much content such that it must scroll, then it automatically becomes a modal Alert.
An Alert may have an AlertType
associated with it to
provide an indication of the nature of the Alert. The implementation may use
this type to play an appropriate sound when the Alert is presented to the
user. See playSound(Display)
Alerts do not accept application-defined Commands
.
If the Alert is visible on the display when changes to its contents are requested by the application, the changes take place automatically. That is, applications need not take any special action to refresh an Alert's display after its contents have been modified.
Field Summary | |
static int |
FOREVER
FOREVER indicates that an Alert is kept alive until the user dismisses it. |
Constructor Summary | |
Alert(String title)
Constructs a new, empty Alert object with the given title. |
|
Alert(String title,
String alertText,
Image alertImage,
AlertType alertType)
Constructs a new Alert object with the given title, content string and image, and alert type. |
Method Summary | |
void |
addCommand(Command cmd)
Commands are not allowed on Alerts, so this method will always throw IllegalStateException whenever it is called. |
int |
getDefaultTimeout()
Get the default time for showing an Alert. |
Image |
getImage()
Gets the Image used in the Alert |
String |
getString()
Gets the text string used in the Alert. |
int |
getTimeout()
Get the time this Alert will be shown. |
AlertType |
getType()
Gets the type of the Alert. |
void |
setCommandListener(CommandListener l)
Listeners are not allowed on Alerts, so this method will always throw IllegalStateException whenever it is called. |
void |
setImage(Image img)
Sets the Image used in the Alert |
void |
setString(String str)
Sets the text string used in the Alert |
void |
setTimeout(int time)
Set the time for which the Alert is to be shown. |
void |
setType(AlertType type)
Sets the type of the Alert. |
Methods inherited from class javax.microedition.lcdui.Screen |
getTicker,
getTitle,
setTicker,
setTitle |
Methods inherited from class javax.microedition.lcdui.Displayable |
isShown,
removeCommand |
Methods inherited from class java.lang.Object |
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Field Detail |
public static final int FOREVER
setTimeout()
to indicate that the Alert is
modal. Instead of waiting for a specified period of time, a modal Alert
will wait for the user to take some explicit action, such as pressing a
button, before proceeding to the next screen.Value -2 is assigned to FOREVER.
Constructor Detail |
public Alert(String title)
Alert(title, null, null, null)
title
- the title string, or nullpublic Alert(String title, String alertText, Image alertImage, AlertType alertType)
getDefaultTimeout()
. If an
Image is provided it must be immutable. The handling and behavior of
specific AlertTypes is described in AlertType
.
null is allowed as the value of the alertType
parameter and indicates that the Alert is not to have a specific alert
type.title
- the title string, or null if there is no titlealertText
- the string contents, or null if there is no
StringalertImage
- the image contents, or null if there is no
ImagealertType
- the type of the Alert, or null if the Alert has
no specific type.Method Detail |
public void addCommand(Command cmd)
cmd
- the Commandpublic int getDefaultTimeout()
FOREVER
, which indicates that Alerts are modal by
default. The value returned will vary across implementations and is
presumably tailored to be suitable for each.FOREVER
public Image getImage()
public String getString()
public int getTimeout()
FOREVER
which indicates that this Alert is modal.FOREVER
public AlertType getType()
public void setCommandListener(CommandListener l)
l
- the Listenerpublic void setImage(Image img)
img
- the Alert's Image, or null if there is no Imagepublic void setString(String str)
str
- the Alert's text string, or null if there is no textpublic void setTimeout(int time)
FOREVER
.time
- timeout in milliseconds, or FOREVER
public void setType(AlertType type)
AlertType
type
- an AlertType, or null if the Alert has no specific
type
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |