|
BenQ Mobile |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.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 (String) and 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 time to be infinity with
setTimeout(Alert.FOREVER)
in which case the Alert is considered to be modal and
the implementation provide 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 AlertType.playSound()
.
Alerts do not accept application-defined commands.
The layout policy is such that the items - strings and images - are filled by default. This means that appended items are placed on the same line with the previous item unless:
The items contained within a container object (an instance of either Form or Alert) may be edited using append, delete, insert, and set methods. An item may be placed within at most one container object. If the application attempts to place an item into a container, and the item is already owned by this or another container, IllegalStateException is thrown. The application must remove the item from its container before inserting it into the new container.
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 a Alert's display after its contents have been modified.
AlertType
Field Summary | |
static Command |
DISMISCOMMAND
A Command delivered to a listener to indicate that
the Alert has been
dismissed. |
static int |
FOREVER
FOREVER indicates that an Alert is kept visible until the user dismisses it. |
Constructor Summary | |
Alert(java.lang.String title)
Constructs a new, empty Alert object with the given title. |
|
Alert(java.lang.String title,
java.lang.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)
Similar to Displayable.addCommand(javax.microedition.lcdui.Command) , however when the
application first adds a command to an Alert ,
DISMISCOMMAND is implicitly removed. |
int |
getDefaultTimeout()
Gets the default time for showing an Alert. |
Image |
getImage()
Gets the Image used in the Alert. |
Gauge |
getIndicator()
Gets the activity indicator for this Alert . |
java.lang.String |
getString()
Gets the text string used in the Alert. |
int |
getTimeout()
Gets the time this Alert will be shown. |
AlertType |
getType()
Gets the type of the Alert. |
void |
removeCommand(Command cmd)
Similar to Displayable.removeCommand(javax.microedition.lcdui.Command) , however when the
application removes the last command from an
Alert , DISMISCOMMAND is implicitly
added. |
void |
setCommandListener(CommandListener l)
Overrides Displayable.setCommandListener(javax.microedition.lcdui.CommandListener) .
|
void |
setImage(Image img)
Sets the Image used in the Alert. |
void |
setIndicator(Gauge indicator)
Sets an activity indicator on this Alert . |
void |
setString(java.lang.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.Displayable |
getHeight, getTicker, getTitle, getWidth, isShown, setTicker, setTitle, sizeChanged |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int FOREVER
FOREVER indicates that an Alert is kept visible until the user
dismisses it. It is used as a value for the parameter to
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.
public static final Command DISMISCOMMAND
Command
delivered to a listener to indicate that
the Alert
has been
dismissed. This Command is implicitly present an on
Alert
whenever
there are no other Commands present. The field values of
DISMISCOMMAND
are as follows:
The label value visible to the application must be as specified
above. However, the implementation may display
DISMISCOMMAND
to the
user using an implementation-specific label.
Attempting to add or remove DISMISCOMMAND
from an Alert
has no
effect. However, DISMISCOMMAND
is treated as an
ordinary Command
if
it is used with other Displayable
types.
Constructor Detail |
public Alert(java.lang.String title)
Constructs a new, empty Alert object with the given title. If null is passed, the Alert will have no title. Calling this constructor is equivalent to calling
Alert(title, null, null, null)
title
- the title string, or nullAlert(String, String, Image, AlertType)
public Alert(java.lang.String title, java.lang.String alertText, Image alertImage, AlertType alertType)
Constructs a new Alert object with the given title, content
string and image, and alert type.
The layout of the contents is implementation dependent.
The timeout value of this new alert is the same value that is
returned by 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 typeMethod Detail |
public int getDefaultTimeout()
Gets the default time for showing an Alert. The value 15 seconds is set as default.
public int getTimeout()
Gets the time this Alert will be shown. This is either a positive value, which indicates a time in milliseconds, or the special value FOREVER, which indicates that this Alert is modal.
public void setTimeout(int time)
Set the time for which the Alert is to be shown. This must either be a positive time value in milliseconds, or the special value FOREVER.
time
- timeout in milliseconds, or FOREVER
java.lang.IllegalArgumentException
- if time is not positive and is
not FOREVERpublic AlertType getType()
public void setType(AlertType type)
AlertType
.
type
- an AlertType, or null
if the Alert has no
specific typepublic java.lang.String getString()
public void setString(java.lang.String str)
Sets the text string used in the Alert.
str
- the Alert's text string, or null if there is no textpublic Image getImage()
public void setImage(Image img)
Sets the Image used in the Alert.
img
- the Alert's image, or null if there is no image
java.lang.IllegalArgumentException
- if img is mutablepublic void setIndicator(Gauge indicator)
Alert
. The
activity indicator is a
Gauge
object. It must be in a restricted state in order for it
to be used as the activity indicator for an Alert
.
The restrictions
are listed above. If the
Gauge
object
violates any of these restrictions,
IllegalArgumentException
is thrown.
If indicator
is null
, this removes any
activity indicator present on this Alert
.
indicator
- the activity indicator for this Alert
,
or null
if
there is to be none
java.lang.IllegalArgumentException
- if indicator
does not
meet the restrictions for its use in an Alert
getIndicator()
public Gauge getIndicator()
Alert
.
Alert's
activity indicator,
or null
if
there is nonesetIndicator(javax.microedition.lcdui.Gauge)
public void addCommand(Command cmd)
Displayable.addCommand(javax.microedition.lcdui.Command)
, however when the
application first adds a command to an Alert
,
DISMISCOMMAND
is implicitly removed. Calling this
method with DISMISCOMMAND
as the parameter has
no effect.
addCommand
in class Displayable
cmd
- the command to be added
java.lang.NullPointerException
- if cmd is null
public void removeCommand(Command cmd)
Displayable.removeCommand(javax.microedition.lcdui.Command)
, however when the
application removes the last command from an
Alert
, DISMISCOMMAND
is implicitly
added. Calling this method with DISMISCOMMAND
as the parameter has no effect.
removeCommand
in class Displayable
cmd
- the command to be removedpublic void setCommandListener(CommandListener l)
Displayable.setCommandListener(javax.microedition.lcdui.CommandListener)
.
If CommandListener l is null, the default listener is
restored.
setCommandListener
in class Displayable
l
- CommandListener
|
BenQ Mobile |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright © 2006 BenQ Mobile GmbH & Co. OHG or respective copyright owner. All Rights Reserved. BenQ Corp. is a trademark licensee of Siemens AG. |
For further information about Mobility Toolkit (MTK) visit our Developer Portal. |