javax.microedition.lcdui
Class 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.

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.

ChoiceGroup

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,
MULTIPLE, or POPUP. 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. Non-null elements
of the
imageElements array may refer to mutable or
immutable images.

getSelectedIndex

public int getSelectedIndex()

Returns the index number of an element in the
ChoiceGroup that is
selected. For ChoiceGroup objects of type
EXCLUSIVE and POPUP
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 MULTIPLEChoice, see getSelectedFlags.

getSelectedFlags

public 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 and POPUP
exactly one element will be selected, unless there are
zero elements in the ChoiceGroup.

setSelectedIndex

For ChoiceGroup objects of type
EXCLUSIVE and POPUP, 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 elementNum parameter
must be within
the range
[0..size()-1], inclusive.

setSelectedFlags

Attempts to set the selected state of every element in the
ChoiceGroup. The array
must be at least as long as the size of the
ChoiceGroup. If the array is
longer, the additional values are ignored.

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 and POPUP, 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.

setFitPolicy

public void setFitPolicy(int fitPolicy)

Sets the application's preferred policy for fitting
Choice element
contents to the available screen space. The set policy applies for all
elements of the Choice object. Valid values are
Choice.TEXT_WRAP_DEFAULT, Choice.TEXT_WRAP_ON,
and Choice.TEXT_WRAP_OFF. Fit policy is a hint, and the
implementation may disregard the application's preferred policy.

getFitPolicy

public int getFitPolicy()

Gets the application's preferred policy for fitting
Choice element
contents to the available screen space. The value returned is the
policy that had been set by the application, even if that value had
been disregarded by the implementation.

getFont

Gets the application's preferred font for
rendering the specified element of this Choice. The
value returned is the font that had been set by the application,
even if that value had been disregarded by the implementation.
If no font had been set by the application, or if the application
explicitly set the font to null, the value is the default
font chosen by the implementation.

The elementNum parameter must be within the range
[0..size()-1], inclusive.

A script enabled browser is required for this page to function properly.A script enabled browser is required for this page to function properly.A script enabled browser is required for this page to function properly.A script enabled browser is required for this page to function properly.