| java.lang.Object javax.microedition.lcdui.Item javax.microedition.lcdui.ChoiceGroup
ChoiceGroup | public class ChoiceGroup extends Item implements Choice(Code) | | 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 Choice interface.
since: MIDP 1.0 |
Inner Class :class CGElement | |
Constructor Summary | |
public | ChoiceGroup(String label, int choiceType) Creates a new, empty ChoiceGroup , specifying its
title and its type.
The type must be one of EXCLUSIVE ,
MULTIPLE , or POPUP . | 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 ,
MULTIPLE , or POPUP . | | ChoiceGroup(String label, int choiceType, String[] stringElements, Image[] imageElements, boolean implicitAllowed) |
Method Summary | |
boolean | acceptFocus() Return whether the Item takes user input focus. | public int | append(String stringPart, Image imagePart) Appends an element to the ChoiceGroup . | public void | delete(int elementNum) Deletes the element referenced by elementNum . | public void | deleteAll() Deletes all elements from this ChoiceGroup . | public int | getFitPolicy() Gets the application's preferred policy for fitting
Choice element
contents to the available screen space. | public Font | getFont(int elementNum) Gets the application's preferred font for
rendering the specified element of this Choice . | public Image | getImage(int elementNum) Gets the Image part of the element referenced by
elementNum . | Image[] | getImageElements() | 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 . | public int | getSelectedIndex() Returns the index number of an element in the
ChoiceGroup that is
selected. | public String | getString(int elementNum) Gets the String part of the element referenced by
elementNum . | String[] | getStringElements() | public void | insert(int elementNum, String stringPart, Image imagePart) Inserts an element into the ChoiceGroup just prior to
the element specified. | public boolean | isSelected(int elementNum) Gets a boolean value indicating whether this element is selected. | public void | set(int elementNum, String stringPart, Image imagePart) Sets the String and Image parts of the
element referenced by elementNum ,
replacing the previous contents of the element. | public void | setFitPolicy(int fitPolicy) Sets the application's preferred policy for fitting
Choice element
contents to the available screen space. | public void | setFont(int elementNum, Font font) Sets the application's preferred font for
rendering the specified element of this 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 . | public void | setSelectedFlags(boolean[] selectedArray) Attempts to set the selected state of every element in the
ChoiceGroup . | public void | setSelectedIndex(int elementNum, boolean selected) For 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. | public int | size() Returns the number of elements in the ChoiceGroup . |
GROW_FACTOR | final static int GROW_FACTOR(Code) | | Optimization for CGElement array size management.
Notice that cgElements.length is not equal to numOfEls.
Use numOfEls only when accessing the array.
|
cgElements | CGElement[] cgElements(Code) | | The array containing the Font of each element (null if no setFont()
method was ever called). If fontEls is non-null, only the elements
which were set by setFont() are non-null.
|
choiceGroupLF | ChoiceGroupLF choiceGroupLF(Code) | | The look&feel associated with this ChoiceGroup.
Set in the constructor.
|
choiceType | int choiceType(Code) | | The type of this ChoiceGroup
|
fitPolicy | int fitPolicy(Code) | | The string fit policy for this ChoiceGroup
'0' by default, which is Choice.TEXT_WRAP_DEFAULT
|
numOfEls | int numOfEls(Code) | | The number of elements in this ChoiceGroup
|
ChoiceGroup | public ChoiceGroup(String label, int choiceType)(Code) | | Creates a new, empty 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 .
Parameters: label - the item's label (see Item Item) Parameters: choiceType - EXCLUSIVE , MULTIPLE ,or POPUP throws: IllegalArgumentException - if choiceType is not one ofEXCLUSIVE , MULTIPLE , or POPUP See Also: Choice.EXCLUSIVE See Also: Choice.MULTIPLE See Also: Choice.IMPLICIT See Also: Choice.POPUP |
ChoiceGroup | public ChoiceGroup(String label, int choiceType, String[] stringElements, Image[] imageElements)(Code) | | 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.
Parameters: label - the item's label (see Item Item) Parameters: choiceType - EXCLUSIVE , MULTIPLE ,or POPUP Parameters: stringElements - set of strings specifying the string parts of theChoiceGroup elements Parameters: imageElements - set of images specifying the image parts ofthe ChoiceGroup elements throws: NullPointerException - if stringElements is null throws: NullPointerException - if the stringElements array containsany null elements throws: IllegalArgumentException - if the imageElements array is non-nulland has a different length from the stringElements array throws: IllegalArgumentException - if choiceType is not one ofEXCLUSIVE , MULTIPLE , or POPUP See Also: Choice.EXCLUSIVE See Also: Choice.MULTIPLE See Also: Choice.IMPLICIT See Also: Choice.POPUP |
ChoiceGroup | ChoiceGroup(String label, int choiceType, String[] stringElements, Image[] imageElements, boolean implicitAllowed)(Code) | | Special constructor used by List
Parameters: label - the item's label (see Item Item) Parameters: choiceType - EXCLUSIVE or MULTIPLE Parameters: stringElements - set of strings specifying the string parts of theChoiceGroup elements Parameters: imageElements - set of images specifying the image parts ofthe ChoiceGroup elements Parameters: implicitAllowed - Flag to allow implicit selection throws: NullPointerException - if stringElements is null throws: NullPointerException - if the stringElements array containsany null elements throws: IllegalArgumentException - if the imageElements array is non-nulland has a different length from the stringElements array throws: IllegalArgumentException - if choiceType is neitherEXCLUSIVE nor MULTIPLE throws: IllegalArgumentException - if any image in the imageElementsarray is mutable See Also: Choice.EXCLUSIVE See Also: Choice.MULTIPLE See Also: Choice.IMPLICIT |
acceptFocus | boolean acceptFocus()(Code) | | Return whether the Item takes user input focus.
return true if contents is not null or haveabstract commands. |
append | public int append(String stringPart, Image imagePart)(Code) | | Appends an element to the ChoiceGroup .
Parameters: stringPart - the string part of the element to be added Parameters: imagePart - the image part of the element to be added, ornull if there is no image part the assigned index of the element throws: NullPointerException - if stringPart isnull |
delete | public void delete(int elementNum)(Code) | | Deletes the element referenced by elementNum .
Parameters: elementNum - the index of the element to be deleted throws: IndexOutOfBoundsException - if elementNum is invalid |
deleteAll | public void deleteAll()(Code) | | Deletes all elements from this ChoiceGroup .
|
getFont | public Font getFont(int elementNum)(Code) | | 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.
Parameters: elementNum - the index of the element, starting from zero the preferred font to use to render the element throws: IndexOutOfBoundsException - if elementNum is invalid See Also: ChoiceGroup.setFont(int elementNum,Font font) |
getImage | public Image getImage(int elementNum)(Code) | | Gets the Image part of the element referenced by
elementNum .
Parameters: elementNum - the number of the element to be queried the image part of the element, or null if there is no image throws: IndexOutOfBoundsException - if elementNum is invalid See Also: ChoiceGroup.getString(int) |
getImageElements | Image[] getImageElements()(Code) | | Helper method, used solely by the native method
call: updatePopupElements()
an array of image elements |
getSelectedFlags | public int getSelectedFlags(boolean[] selectedArray_return)(Code) | | 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 .
the number of selected elements in the ChoiceGroup Parameters: selectedArray_return - array to contain the results throws: IllegalArgumentException - if selectedArray_return is shorter than the size of the ChoiceGroup throws: NullPointerException - if selectedArray_return is null See Also: ChoiceGroup.setSelectedFlags |
getSelectedIndex | public int getSelectedIndex()(Code) | | 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 MULTIPLE
Choice , see
ChoiceGroup.getSelectedFlags getSelectedFlags .
index of selected element, or -1 if none See Also: ChoiceGroup.setSelectedIndex |
getStringElements | String[] getStringElements()(Code) | | Helper method, used solely by the native method
call: updatePopupElements()
an array of string elements |
insert | public void insert(int elementNum, String stringPart, Image imagePart)(Code) | | Inserts an element into the ChoiceGroup just prior to
the element specified.
Parameters: elementNum - the index of the element where insertion is to occur Parameters: stringPart - the string part of the element to be inserted Parameters: imagePart - the image part of the element to be inserted,or null if there is no image part throws: IndexOutOfBoundsException - if elementNum is invalid throws: NullPointerException - if stringPart is null |
isSelected | public boolean isSelected(int elementNum)(Code) | | Gets a boolean value indicating whether this element is selected.
Parameters: elementNum - the index of the element to be queried selection state of the element throws: IndexOutOfBoundsException - if elementNum is invalid |
set | public void set(int elementNum, String stringPart, Image imagePart)(Code) | | Sets the String and Image parts of the
element referenced by elementNum ,
replacing the previous contents of the element.
Parameters: elementNum - the index of the element to be set Parameters: stringPart - the string part of the new element Parameters: imagePart - the image part of the element, or null if there is no image part throws: IndexOutOfBoundsException - if elementNum is invalid throws: NullPointerException - if stringPart isnull |
setFont | public void setFont(int elementNum, Font font)(Code) | | Sets the application's preferred font for
rendering the specified element of this 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.
Parameters: elementNum - the index of the element, starting from zero Parameters: font - the preferred font to use to render the element throws: IndexOutOfBoundsException - if elementNum is invalid See Also: ChoiceGroup.getFont |
setSelectedFlags | public void setSelectedFlags(boolean[] selectedArray)(Code) | | 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.
Parameters: selectedArray - an array in which the method collect theselection status throws: IllegalArgumentException - if selectedArray is shorter than the size of the ChoiceGroup throws: NullPointerException - if the selectedArray is null See Also: ChoiceGroup.getSelectedFlags |
setSelectedIndex | public void setSelectedIndex(int elementNum, boolean selected)(Code) | | For 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.
Parameters: elementNum - the number of the element. Indexing of theelements is zero-based Parameters: selected - the new state of the element true=selected ,false=not selected throws: IndexOutOfBoundsException - if elementNum is invalid See Also: ChoiceGroup.getSelectedIndex |
size | public int size()(Code) | | Returns the number of elements in the ChoiceGroup .
the number of elements in the ChoiceGroup |
|
|