|
MID Profile | |||||||||
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 (Strings) and images, and which handles events like other screens.
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.
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.
Field Summary | |
static int |
FOREVER
FOREVER indicates that an Alert is kept alive until user dismisses it. |
Constructor Summary | |
Alert(String title)
Constructs a new, empty Alert object with the given title. |
Method Summary | |
void |
addCommand(Command cmd)
Commands are not allowed on Alerts, so this method will always throw IllegalStateException whenever it is called. |
int |
appendImage(Image img)
Adds an item consisting of one Image to the form. |
int |
appendItem(ImageItem item)
Adds an ImageItem to the Alert. |
int |
appendItem(StringItem item)
Adds an StringItem to the Alert. |
int |
appendString(String str)
Adds an item consisting of one String to the form. |
void |
deleteItem(int itemNum)
Deletes the Item referenced by itemNum. |
int |
getDefaultTimeout()
Get the default time the Alert is shown in milliseconds. |
Item |
getItemAt(int itemNum)
Gets the item at given position. |
int |
getSize()
Gets the number of items in the Alert. |
int |
getTimeout()
Get the time the Alert is shown in milliseconds. |
void |
insertItem(int itemNum,
ImageItem item)
Inserts an Image into the Alert just prior to the item specified. |
void |
insertItem(int itemNum,
StringItem item)
Inserts a string into the Alert just prior to the item specified. |
void |
setItem(int itemNum,
Item item)
Sets the item referenced by itemNum to the specified item, replacing the previous item. |
void |
setListener(CommandListener l)
Listeners are not allowed on Alerts, so this method will always throw IllegalStateException whenever it is called. |
void |
setTimeout(int time)
Set the time the Alert is shown in milliseconds. |
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,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Field Detail |
public static final int FOREVER
FOREVER indicates that an Alert is kept alive until user dismisses
it. It is a parameter in
setTimeout()
to indicate that the alert is modal and an "ok" or "done" command will be
associated with it.
Value -2 is assigned to FOREVER.
Constructor Detail |
public Alert(String title)
title
- the title string, or nullMethod Detail |
public int getDefaultTimeout()
public int getTimeout()
public void setTimeout(int time)
time
- time in milliseconds. The Alert can be made modal
by setting a special value FOREVER
.getDefaultTimeout()
public int appendString(String str)
Adds an item consisting of one String to the form. The effect visible to the application is identical to
appendItem(new StringItem(null, str))
str
- the textpublic int appendImage(Image img)
Adds an item consisting of one Image to the form. The effect visible to the application is identical to
appendItem(new ImageItem(null, img, ImageItem.LAYOUT_DEFAULT, null))
The image must be immutable, otherwise IllegalArgumentException is
thrown. An immutable copy of a mutable image can be created using createImage(Image)
.
img
- the image to be addedImage
public int appendItem(ImageItem item)
ImageItem
specify otherwise. For layout control of the images, see ImageItem
. item
- the ImageItem
to be added.public int appendItem(StringItem item)
item
- the StringItem
to be added.public void insertItem(int itemNum, ImageItem item)
appendItem
.itemNum
- the location at which the new item is to be inserteditem
- the image item to be addedpublic void insertItem(int itemNum, StringItem item)
appendString
.itemNum
- the number of the item. Indexing of the items is zero-based.item
- the string item to be addedpublic void deleteItem(int itemNum)
itemNum
- the number of the item to be deletedpublic void setItem(int itemNum, Item item)
The result will be identical to
insertItem(n, item); deleteItem(n+1);
although the implementation may optimize the repainting and array element copying.
itemNum
- the number of the item to be replaceditem
- the new itempublic Item getItemAt(int itemNum)
itemNum
- the index of itempublic int getSize()
public void addCommand(Command cmd)
cmd
- the Commandpublic void setListener(CommandListener l)
l
- the Listener
|
MID Profile | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |