|
MIDP3.0 | |||||||||
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
public 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.
Field Summary |
---|
Fields inherited from class javax.microedition.lcdui.Item |
---|
BUTTON, HYPERLINK, LAYOUT_2, LAYOUT_BOTTOM, LAYOUT_CENTER, LAYOUT_DEFAULT, LAYOUT_EXPAND, LAYOUT_LEFT, LAYOUT_NEWLINE_AFTER, LAYOUT_NEWLINE_BEFORE, LAYOUT_RIGHT, LAYOUT_SHRINK, LAYOUT_TOP, LAYOUT_VCENTER, LAYOUT_VEXPAND, LAYOUT_VSHRINK, PLAIN |
Fields inherited from interface javax.microedition.lcdui.Choice |
---|
EXCLUSIVE, IMPLICIT, MULTIPLE, POPUP, TEXT_WRAP_DEFAULT, TEXT_WRAP_OFF, TEXT_WRAP_ON |
Constructor Summary | |
---|---|
ChoiceGroup(java.lang.String label,
int choiceType)
Creates a new, empty ChoiceGroup , specifying its title
and its type. |
|
ChoiceGroup(java.lang.String label,
int choiceType,
java.lang.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(java.lang.String stringPart,
Image imagePart)
Appends an element to the ChoiceGroup . |
void |
delete(int elementNum)
Deletes the element referenced by elementNum . |
void |
deleteAll()
Deletes all elements from this ChoiceGroup . |
int |
getFitPolicy()
Gets the application's preferred policy for fitting Choice
element contents to the available screen space. |
Font |
getFont(int elementNum)
Gets the application's preferred font for rendering the specified element of this Choice . |
Image |
getImage(int elementNum)
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. |
java.lang.String |
getString(int elementNum)
Gets the String part of the element referenced by
elementNum . |
void |
insert(int elementNum,
java.lang.String stringPart,
Image imagePart)
Inserts an element into the ChoiceGroup just prior to the
element specified. |
boolean |
isEnabled(int elementNum)
Gets a boolean value indicating whether the specified Choice element is enabled or disabled. |
boolean |
isSelected(int elementNum)
Gets a boolean value indicating whether this element is selected. |
void |
set(int elementNum,
java.lang.String stringPart,
Image imagePart)
Sets the String and Image parts of the
element referenced by elementNum , replacing the previous
contents of the element. |
void |
setEnabled(int elementNum,
boolean isEnabled)
Sets the Choice element into enabled or
disabled mode. |
void |
setFitPolicy(int fitPolicy)
Sets the application's preferred policy for fitting Choice
element contents to the available screen space. |
void |
setFont(int elementNum,
Font font)
Sets the application's preferred font for rendering the specified element of this Choice . |
void |
setSelectedFlags(boolean[] selectedArray)
Attempts to set the selected state of every element in the ChoiceGroup . |
void |
setSelectedIndex(int elementNum,
boolean selected)
For ChoiceGroup objects of type MULTIPLE ,
this simply sets an individual element's selected state. |
int |
size()
Returns the number of elements in the ChoiceGroup . |
Methods inherited from class javax.microedition.lcdui.Item |
---|
addCommand, getCommands, getLabel, getLayout, getLayoutHint, getMinimumHeight, getMinimumWidth, getPreferredHeight, getPreferredWidth, notifyStateChanged, removeCommand, setCommand, setDefaultCommand, setItemCommandListener, setLabel, setLayout, setLayoutHint, setPreferredSize |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ChoiceGroup(java.lang.String label, int choiceType)
ChoiceGroup
, specifying its title
and its type. The type must be one of EXCLUSIVE
,
MULTIPLE
, or POPUP
. The
IMPLICIT
choice type is not allowed within a
ChoiceGroup
.
label
- the item's label (see Item
)choiceType
- EXCLUSIVE
, MULTIPLE
, or
POPUP
java.lang.IllegalArgumentException
- if choiceType
is not one of
EXCLUSIVE
, MULTIPLE
, or
POPUP
Choice.EXCLUSIVE
,
Choice.MULTIPLE
,
Choice.IMPLICIT
,
Choice.POPUP
public ChoiceGroup(java.lang.String label, int choiceType, java.lang.String[] stringElements, Image[] imageElements)
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.
label
- the item's label (see Item
)choiceType
- EXCLUSIVE
, MULTIPLE
, or
POPUP
stringElements
- set of strings specifying the string parts of the
ChoiceGroup
elementsimageElements
- set of images specifying the image parts of the
ChoiceGroup
elements
java.lang.NullPointerException
- if stringElements
is null
java.lang.NullPointerException
- if the stringElements
array contains any
null
elements
java.lang.IllegalArgumentException
- if the imageElements
array is non-null and has
a different length from the stringElements
array
java.lang.IllegalArgumentException
- if choiceType
is not one of
EXCLUSIVE
, MULTIPLE
, or
POPUP
Choice.EXCLUSIVE
,
Choice.MULTIPLE
,
Choice.IMPLICIT
,
Choice.POPUP
Method Detail |
---|
public int size()
ChoiceGroup
.
size
in interface Choice
ChoiceGroup
public java.lang.String getString(int elementNum)
String
part of the element referenced by
elementNum
.
The elementNum
parameter must be within the range
[0..size()-1]
, inclusive.
getString
in interface Choice
elementNum
- the index of the element to be queried, starting from zero
java.lang.IndexOutOfBoundsException
- if elementNum
is invalidgetImage(int)
public Image getImage(int elementNum)
Image
part of the element referenced by
elementNum
.
The elementNum
parameter must be within the range
[0..size()-1]
, inclusive.
getImage
in interface Choice
elementNum
- the index of the element to be queried, starting from zero
java.lang.IndexOutOfBoundsException
- if elementNum is invalidgetString(int)
public int append(java.lang.String stringPart, Image imagePart)
ChoiceGroup
.
append
in interface Choice
stringPart
- the string part of the element to be addedimagePart
- the image part of the element to be added, or
null
if there is no image part
java.lang.NullPointerException
- if stringPart
is null
public void insert(int elementNum, java.lang.String stringPart, Image imagePart)
ChoiceGroup
just prior to the
element specified.
The elementNum
parameter must be within the range
[0..size()-1]
, inclusive.
insert
in interface Choice
elementNum
- the index of the element where insertion is to occur, starting from zerostringPart
- the string part of the element to be insertedimagePart
- the image part of the element to be inserted, or
null
if there is no image part
java.lang.IndexOutOfBoundsException
- if elementNum
is invalid
java.lang.NullPointerException
- if stringPart
is null
public void delete(int elementNum)
elementNum
.
The elementNum
parameter must be within the range
[0..size()-1]
, inclusive.
delete
in interface Choice
elementNum
- the index of the element to be deleted, starting from zero
java.lang.IndexOutOfBoundsException
- if elementNum
is invalidpublic void deleteAll()
ChoiceGroup
.
deleteAll
in interface Choice
public void set(int elementNum, java.lang.String stringPart, Image imagePart)
String
and Image
parts of the
element referenced by elementNum
, replacing the previous
contents of the element.
The elementNum
parameter must be within the range
[0..size()-1]
, inclusive.
set
in interface Choice
elementNum
- the index of the element to be set, starting from zerostringPart
- the string part of the new elementimagePart
- the image part of the element, or null
if there
is no image part
java.lang.IndexOutOfBoundsException
- if elementNum
is invalid
java.lang.NullPointerException
- if stringPart
is null
public boolean isSelected(int elementNum)
The elementNum
parameter must be within the range
[0..size()-1]
, inclusive.
isSelected
in interface Choice
elementNum
- the index of the element to be queried, starting from zero
java.lang.IndexOutOfBoundsException
- if elementNum
is invalidpublic int getSelectedIndex()
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 MULTIPLE
Choice
,
see getSelectedFlags
.
getSelectedIndex
in interface Choice
-1
if nonesetSelectedIndex(int, boolean)
public int getSelectedFlags(boolean[] selectedArray_return)
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
.
getSelectedFlags
in interface Choice
selectedArray_return
- array to contain the results
ChoiceGroup
java.lang.IllegalArgumentException
- if selectedArray_return
is shorter than the
size of the ChoiceGroup
java.lang.NullPointerException
- if selectedArray_return
is nullsetSelectedFlags(boolean[])
public void setSelectedIndex(int elementNum, boolean selected)
ChoiceGroup
objects of type MULTIPLE
,
this simply sets an individual element's selected state.
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.
setSelectedIndex
in interface Choice
elementNum
- the index of the element, starting from zeroselected
- the new state of the element true=selected
,
false=not
selected
java.lang.IndexOutOfBoundsException
- if elementNum
is invalidgetSelectedIndex()
public void setSelectedFlags(boolean[] selectedArray)
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.
setSelectedFlags
in interface Choice
selectedArray
- an array in which the method collect the selection status
java.lang.IllegalArgumentException
- if selectedArray
is shorter than the size of
the ChoiceGroup
java.lang.NullPointerException
- if the selectedArray
is null
getSelectedFlags(boolean[])
public void setFitPolicy(int fitPolicy)
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.
setFitPolicy
in interface Choice
fitPolicy
- preferred content fit policy for choice elements
java.lang.IllegalArgumentException
- if fitPolicy
is invalidgetFitPolicy()
public int getFitPolicy()
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.
getFitPolicy
in interface Choice
Choice.TEXT_WRAP_DEFAULT
, Choice.TEXT_WRAP_ON
, or
Choice.TEXT_WRAP_OFF
setFitPolicy(int)
public void setFont(int elementNum, Font font)
Choice
. An element's font is a hint, and the
implementation may disregard the application's preferred font.
The elementNum
parameter must be within the range
[0..size()-1]
, inclusive.
The font
parameter must be a valid Font
object or null
. If the font
parameter is
null
, the implementation must use its default font to
render the element.
setFont
in interface Choice
elementNum
- the index of the element, starting from zerofont
- the preferred font to use to render the element
java.lang.IndexOutOfBoundsException
- if elementNum
is invalidgetFont(int)
public Font getFont(int elementNum)
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.
getFont
in interface Choice
elementNum
- the index of the element, starting from zero
java.lang.IndexOutOfBoundsException
- if elementNum
is invalidsetFont(int elementNum, Font font)
public void setEnabled(int elementNum, boolean isEnabled)
Choice
element into enabled or
disabled mode. The set mode applies for the
element of the Choice
object specified by the elementNum
parameter. A disabled Choice element SHOULD be visually
different from an enabled Choice element.
The elementNum
parameter must be within the
range [0..size()-1]
, inclusive.
setEnabled
in interface Choice
elementNum
- the index of the element to which the mode change
is applied, the index starts from zeroisEnabled
- true if enabled, false if disabled
java.lang.IndexOutOfBoundsException
- if elementNum
is
invalidisEnabled(int)
public boolean isEnabled(int elementNum)
The elementNum
parameter must be within the range
[0..size()-1]
, inclusive.
isEnabled
in interface Choice
elementNum
- the index of the element to be queried
java.lang.IndexOutOfBoundsException
- if elementNum
is
invalid
|
MIDP3.0 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |