|
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectjavax.microedition.lcdui.Item
javax.microedition.lcdui.ChoiceGroup
A ChoiceGroup is a group of selectable elements intended to be
placed within a
Form. The group may be created with a mode that requires a
single choice to be made or that allows multiple choices. The
implementation is responsible for providing the graphical representation of
these modes and must provide visually different graphics for different
modes. For example, it might use "radio buttons" for the single choice
mode and "check boxes" for the multiple choice mode.
Note: most of the essential methods have been specified in
the Choice interface.
| Field Summary |
| Fields inherited from interface javax.microedition.lcdui.Choice |
EXCLUSIVE, IMPLICIT, MULTIPLE |
| Constructor Summary | |
ChoiceGroup(String label,
int choiceType)
Creates a new, empty ChoiceGroup, specifying its title and its type. |
|
ChoiceGroup(String label,
int choiceType,
String[] stringElements,
Image[] imageElements)
Creates a new ChoiceGroup, specifying its title, the type of the ChoiceGroup, and an array of Strings and Images to be used as its initial contents. |
|
| Method Summary | |
int |
append(String stringElement,
Image imageElement)
Appends an element to the Choice. |
void |
delete(int index)
Deletes the element referenced by elementNum. |
Image |
getImage(int index)
Gets the Image part of the element referenced by elementNum. |
int |
getSelectedFlags(boolean[] selectedArray_return)
Queries the state of a ChoiceGroup and returns the state of all elements in the boolean array selectedArray_return. |
int |
getSelectedIndex()
Returns the index number of an element in the ChoiceGroup that is selected. |
String |
getString(int index)
Gets the String part of the element referenced by elementNum. |
void |
insert(int index,
String stringElement,
Image imageElement)
Inserts an element into the Choice just before to the element specified. |
boolean |
isSelected(int index)
Gets a boolean value indicating whether this element is selected. |
void |
set(int index,
String stringElement,
Image imageElement)
Sets the element referenced by elementNum to the specified element, replacing the previous contents of the element. |
void |
setSelectedFlags(boolean[] selectedArray)
Attempts to set the selected state of every element in the ChoiceGroup. |
void |
setSelectedIndex(int index,
boolean selected)
For ChoiceGroup objects of type MULTIPLE, this simply sets an individual element's selected state. |
int |
size()
Gets the number of elements present. |
| Methods inherited from class javax.microedition.lcdui.Item |
getLabel, setLabel |
| Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public ChoiceGroup(String label,
int choiceType)
label - the item's label (see Item)choiceType - either EXCLUSIVE or MULTIPLE
IllegalArgumentException - if choice type is neither
EXCLUSIVE nor MULTIPLEChoice.EXCLUSIVE,
Choice.MULTIPLE,
Choice.IMPLICIT
public ChoiceGroup(String label,
int choiceType,
String[] stringElements,
Image[] imageElements)
Creates a new ChoiceGroup, specifying its title, the type of the ChoiceGroup, and an array of Strings and Images to be used as its initial contents.
The type must be one of EXCLUSIVE or MULTIPLE. The IMPLICIT type is not allowed for ChoiceGroup.
The stringElements array must be non-null and every array element must also be non-null. The length of the stringElements array determines the number of elements in the ChoiceGroup. The imageElements array may be null to indicate that the ChoiceGroup elements have no images. If the imageElements array is non-null, it must be the same length as the stringElements array. Individual elements of the imageElements array may be null in order to indicate the absence of an image for the corresponding ChoiceGroup element.
label - the item's label (see Item)choiceType - EXCLUSIVE or MULTIPLEstringElements - set of strings specifying the string parts of the
ChoiceGroup elementsimageElements - set of images specifying the image parts of
the ChoiceGroup elements
NullPointerException - if stringElements is null
NullPointerException - if the stringElements array contains
any null elements
IllegalArgumentException - if the imageElements array is non-null
and has a different length from the stringElements array
IllegalArgumentException - if choiceType is neither
EXCLUSIVE nor MULTIPLE
IllegalArgumentException - if any image in the imageElements array is mutableChoice.EXCLUSIVE,
Choice.MULTIPLE,
Choice.IMPLICIT| Method Detail |
public int size()
ChoiceGets the number of elements present.
size in interface Choicepublic String getString(int index)
ChoiceGets the String part of the element referenced by elementNum. The elementNum parameter must be within the range [0..size()-1], inclusive.
getString in interface Choiceindex - the index of the element to be queried
IndexOutOfBoundsException - if index is invalidgetImage(int)public Image getImage(int index)
ChoiceGets the Image part of the element referenced by elementNum. The elementNum parameter must be within the range [0..size()-1], inclusive.
getImage in interface Choiceindex - the number of the element to be queried
IndexOutOfBoundsException - if index is invalidgetString(int)
public int append(String stringElement,
Image imageElement)
ChoiceAppends an element to the Choice. The added element will be the last element of the Choice. The size of the Choice grows by one.
append in interface ChoicestringElement - the string part of the element to be addedimageElement - the image part of the element to be added, or null if
there is no image part
IllegalArgumentException - if the image is mutable
NullPointerException - if stringElement is null
public void insert(int index,
String stringElement,
Image imageElement)
ChoiceInserts an element into the Choice just before to the element specified. The size of the Choice grows by one. The elementNum parameter must be within the range [0..size()-1], inclusive.
insert in interface Choiceindex - the index of the element where insertion is to occurstringElement - the string part of the element to be insertedimageElement - the image part of the element to be inserted,
or null if there is no image part
IndexOutOfBoundsException - if index is invalid
IllegalArgumentException - if the image is mutable
NullPointerException - if stringElement is nullpublic void delete(int index)
ChoiceDeletes the element referenced by elementNum. The size of the Choice shrinks by one. It is legal to delete all elements from a Choice. The elementNum parameter must be within the range [0..size()-1], inclusive.
delete in interface Choiceindex - the index of the element to be deleted
IndexOutOfBoundsException - if index is invalid
public void set(int index,
String stringElement,
Image imageElement)
ChoiceSets the element referenced by elementNum to the specified element, replacing the previous contents of the element. The elementNum parameter must be within the range [0..size()-1], inclusive.
set in interface Choiceindex - the index of the element to be setstringElement - the string part of the new elementimageElement - the image part of the element, or null if there is
no image part
IndexOutOfBoundsException - if index is invalid
IllegalArgumentException - if the image is mutable
NullPointerException - if stringElement is nullpublic boolean isSelected(int index)
ChoiceGets a boolean value indicating whether this element is selected. The elementNum parameter must be within the range [0..size()-1], inclusive.
isSelected in interface Choiceindex - the index of the element to be queried
IndexOutOfBoundsException - if index is invalidpublic int getSelectedIndex()
Returns the index number of an element in the ChoiceGroup that is selected. For ChoiceGroup objects of type EXCLUSIVE there is at most one element selected, so this method is useful for determining the user's choice. Returns -1 if there are no elements in the ChoiceGroup.
For ChoiceGroup objects of type MULTIPLE, this always returns -1 because no
single value can in general represent the state of such a ChoiceGroup.
To get the complete state of a MULTIPLE Choice, see getSelectedFlags.
getSelectedIndex in interface Choicepublic int getSelectedFlags(boolean[] selectedArray_return)
Queries the state of a ChoiceGroup and returns the state of all elements in the boolean array selectedArray_return. NOTE: this is a result parameter. It must be at least as long as the size of the ChoiceGroup as returned by size(). If the array is longer, the extra elements are set to false.
For ChoiceGroup objects of type MULTIPLE, any number of elements may be selected and set to true in the result array. For ChoiceGroup objects of type EXCLUSIVE, exactly one element will be selected, unless there are zero elements in the ChoiceGroup.
getSelectedFlags in interface ChoiceselectedArray_return - array to contain the results.
IllegalArgumentException - if selectedArray_return is shorter
than the size of the ChoiceGroup.
NullPointerException - if selectedArray_return is null.
public void setSelectedIndex(int index,
boolean selected)
For ChoiceGroup objects of type MULTIPLE, this simply sets an individual element's selected state.
For ChoiceGroup objects of type EXCLUSIVE, this can be used only to
select an element. That is, the selected parameter must
be true . When an element is selected, the previously
selected element is deselected. If selected is
false , this call is ignored.
For both list types, the index parameter must be within the range [0..size()-1], inclusive.
setSelectedIndex in interface Choiceindex - the number of the element. Indexing of the elements is zero-based.selected - the new state of the element true=selected, false=not selected.
IndexOutOfBoundsException - if index is invalidpublic void setSelectedFlags(boolean[] selectedArray)
For ChoiceGroup objects of type MULTIPLE, this sets the selected state of every element in the Choice. An arbitrary number of elements may be selected.
For ChoiceGroup objects of type EXCLUSIVE, exactly one array
element must have the value true. If no element is true, the first element
in the Choice will be selected. If two or more elements are true, the
implementation will choose the first true element and select it.
setSelectedFlags in interface ChoiceselectedArray - an array in which the method collect the selection status
IllegalArgumentException - if selectedArray is shorter than the
size of the ChoiceGroup.
NullPointerException - if the selectedArray is null.
|
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
| Generated on 2003-10-17 | For further information and updates, please visit Siemens mobile Developer Portal |