|
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.Form
A Form is a Screen that contains an arbitrary mixture of items: images,
read-only text fields, editable text fields, editable date fields, gauges,
and choice groups. In general, any subclass of the
Item
class may be contained within a form.
The implementation handles layout, traversal, and scrolling.
None of the components contained
within has any internal scrolling; the entire contents
scrolls together. Note that this differs
from the behavior of other classes, the List for example,
where only the interior scrolls.
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.
As with other screens, the layout policy in most devices is vertical. In forms this applies to items involving user input. So, a new line is always started for focusable items like TextField, DateField, Gauge or ChoiceGroup.
Strings and images, which do not involve user interactions,
behave differently; they are
filled in horizontal lines, unless newline is embedded in the
string or layout directives of the ImageItem
force a new line.
Contents will be wrapped (for text) or clipped (for
images) to fit the width of the display, and scrolling will
occur vertically as necessary. There will be no horizontal
scrolling.
If the Form is visible on the display when changes to its contents are requested by the application, the changes take place immediately. That is, applications need not take any special action to refresh a Form's display after its contents have been modified.
Notes for application developers:
Constructor Summary | |
Form(String title)
Creates a new, empty Form. |
|
Form(String title,
Item[] items)
Creates a new Form with the specified contents. |
Method Summary | |
int |
appendImage(Image img)
Adds an item consisting of one Image to the form. |
int |
appendItem(Item item)
Adds an Item into the Form. |
int |
appendString(String str)
Adds an item consisting of one String to the form. |
void |
deleteItem(int itemNum)
Deletes the Item referenced by itemNum. |
Item |
getItemAt(int itemNum)
Gets the item at given position. |
int |
getSize()
Gets the number of items in the Form. |
int |
insertItem(int itemNum,
Item item)
Inserts an item into the Form 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 |
setItemStateListener(ItemStateListener iListener)
Sets the ItemStateListener for the Form, replacing any previous ItemStateListener. |
Methods inherited from class javax.microedition.lcdui.Screen |
getTicker,
getTitle,
setTicker,
setTitle |
Methods inherited from class javax.microedition.lcdui.Displayable |
addCommand,
isShown,
removeCommand,
setListener |
Methods inherited from class java.lang.Object |
equals,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Constructor Detail |
public Form(String title)
title
- the Form's title, or null for no titlepublic Form(String title, Item[] items)
title
- the Form's title stringitems
- the array of Items
to be added.Method Detail |
public int appendItem(Item item)
Images are laid out in the same manner as strings, unless the layout
directives of ImageItem
specify otherwise. Focusable
items (TextField, ChoiceGroup, DateField, and Gauge) are placed on their
own horizontal lines.
item
- the Item
to be added.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 String to be addedpublic 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))
img
- the image to be addedpublic int insertItem(int itemNum, Item item)
Inserts an item into the Form just prior to the item specified. The size of the Form grows by one.
The semantics are otherwise identical to
appendItem
.
itemNum
- the number of the item. Indexing of the items is zero-based.item
- the item to be addedpublic void deleteItem(int itemNum)
itemNum
- the number of the item. Indexing of the items is zero-based.public void setItem(int itemNum, Item item)
The end result is equal to
insertItem(n, item); deleteItem(n+1);
although the implementation may optimize the repainting
and usage of the array that stores the items.
itemNum
- the number of the item. Indexing of the items is zero-based.item
- the item to be replaced.public Item getItemAt(int itemNum)
itemNum
- the index of itempublic void setItemStateListener(ItemStateListener iListener)
iListener
- the new listener, or null to remove itpublic int getSize()
|
MID Profile | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |