|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectnet.rim.device.api.ui.Field
net.rim.device.api.ui.component.CheckboxField
public class CheckboxField
Contains a checkbox control.
Behaviour
Displays a checkbox before the text label. In the default font, this box
appears either empty, or containing a check mark, depending upon the state of
the field.
When this field has focus, the box appears inverted and the text label redrawn with the focus colors.
Pressing the spacebar when a checkbox field has the focus toggles its state.
| Field Summary | ||
|---|---|---|
static long |
NO_USE_ALL_WIDTH
Use this style to indicate the field should use only as much horizontal space as necessary. |
|
| Constructor Summary | ||
|---|---|---|
CheckboxField()
Creates a new CheckboxField instance. |
||
CheckboxField(String label,
boolean checked)
Constructs a new CheckboxField instance with label and starting state. |
||
CheckboxField(String label,
boolean checked,
long style)
Constructs a new CheckboxField instance with label, starting state, and style. |
||
| Method Summary | ||
|---|---|---|
protected void |
drawFocus(Graphics graphics,
boolean on)
Draws the focus on both icon and the text label for this field. |
|
AccessibleContext |
getAccessibleContext()
Returns accessible representation of the field for a screen reader. |
|
boolean |
getChecked()
Retrieves this field's state. |
|
void |
getFocusRect(XYRect rect)
Retrieves this field's current focus region. |
|
String |
getLabel()
Retrieves this field's label string. |
|
int |
getPreferredHeight()
Retrieves this field's preferred height. |
|
int |
getPreferredWidth()
Retrieves this field's preferred width. |
|
protected boolean |
invokeAction(int action)
Invokes an action on this field. |
|
protected boolean |
keyChar(char key,
int status,
int time)
Traps SPACE key generation events. |
|
protected boolean |
keyDown(int keycode,
int time)
Handles key down events. |
|
protected void |
layout(int width,
int height)
Lays out this field's contents. |
|
protected void |
makeContextMenu(ContextMenu contextMenu)
Builds this field's context menu. |
|
protected int |
moveFocus(int amount,
int status,
int time)
Handles moving the focus within this field. |
|
protected void |
onFocus(int direction)
Invoked when a field receives the focus. |
|
protected void |
onUnfocus()
Invoked when a field loses the focus. |
|
protected void |
paint(Graphics graphics)
Redraws this field. |
|
void |
setChecked(boolean checked)
Sets the state of this field. |
|
void |
setEditable(boolean editable)
Set the editable state of this field. |
|
void |
setLabel(String label)
Sets this field's label. |
|
String |
toString()
Returns state as a String, "[Yes]" or "[No]". |
|
protected boolean |
touchEvent(TouchEvent message)
Traps touch input events. |
|
protected boolean |
trackwheelClick(int status,
int time)
Indicates a trackwheel click event. |
|
protected boolean |
trackwheelUnclick(int status,
int time)
Indicates a trackwheel release event. |
|
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final long NO_USE_ALL_WIDTH
| Constructor Detail |
|---|
public CheckboxField()
This builds an unchecked checkbox field with no label.
If full available width is not desired, then CheckboxField.NO_USE_ALL_WIDTH style
must be specified using the appropriate constructor.
public CheckboxField(String label,
boolean checked)
This builds a checkbox field with the Field.EDITABLE and
Field.FOCUSABLE styles.
If full available width is not desired, then CheckboxField.NO_USE_ALL_WIDTH style
must be specified using the appropriate constructor.
label - Label string for this field.checked - Initial state of this field; true for checked, false for
unchecked.
public CheckboxField(String label,
boolean checked,
long style)
This builds a checkbox field with the Field.EDITABLE and
Field.FOCUSABLE styles.
If full available width is not desired, then CheckboxField.NO_USE_ALL_WIDTH style
must be specified.
label - Label string for this field.checked - Initial state of this field; true for checked, false for
unchecked.style - The style for this field.| Method Detail |
|---|
protected void drawFocus(Graphics graphics,
boolean on)
drawFocus in class Fieldgraphics - Graphics context for drawing the focus.on - True if the focus should be set; otherwise, false.public boolean getChecked()
public String getLabel()
public int getPreferredHeight()
Field.getPreferredHeight() for more information.
Managers may make use of this value during layout.
getPreferredHeight in class Fieldpublic int getPreferredWidth()
Field.getPreferredWidth() for more information.
Managers make use of this value during layout.
getPreferredWidth in class Fieldprotected boolean invokeAction(int action)
Field.ACTION_INVOKE, which toggles this field from being checked and unchecked.
If action is not a recognized action then this method does nothing and
returns false, indicating that the action was not consumed.
Note that if this field is not editable (ie. Field.isEditable() returns false)
then the action will not be consumed.
invokeAction in class Fieldaction - the action to be performed on this field.
true if the action was consumed; false
if the action was not consumed.
protected boolean keyChar(char key,
int status,
int time)
This method handles and consumes a key generation event, if it's the SPACE key that's generated; otherwise, this method does nothing and does not consume the event.
If the key pressed was the space bar, then this method toggles the state of this field (prompting a repaint to show the new state of the checkbox).
keyChar in class Fieldkey - Character generated by the event.status - Modifier key status (this parameter is ignored).time - Number of milliseconds since the device was turned on.
protected boolean keyDown(int keycode,
int time)
This method handles and consumes a key generation event, if it's the "action"(5) key (for reduced keyboard device) that's generated; otherwise, this method does nothing and does not consume the event.
keyDown in class Fieldkeycode - Code of key pressed.time - Number of milliseconds since the device was turned on.
protected void layout(int width,
int height)
This field's manager invokes this method during the layout process to instruct this field to arrange its contents, given an amount of available space.
layout in class Fieldwidth - Amount of available horizontal space.height - Amount of available vertical space.protected void makeContextMenu(ContextMenu contextMenu)
The framework uses Field.getContextMenu() to invoke this method to
construct this field's context menu. You shouldn't invoke this method
directly.
makeContextMenu in class FieldcontextMenu - Context menu to create.ContextMenu
protected int moveFocus(int amount,
int status,
int time)
This field's manager invokes this method only when this field
already has the focus.
If this field is Field.EDITABLE, then this method handles the case
where the user ALT-rolls the trackwheel (trapping these events to toggle
the state of the checkbox). Otherwise, this field simply passes the roll
amount of the event on.
moveFocus in class Fieldamount - Amount rolled. This value is either entirely consumed if
the field is Field.EDITABLE, or passed on entirely if the field is not
editable.status - Modifier key state: if not
KeypadListener.STATUS_ALT, then this method does nothing and
returns the entire roll amount.time - Number of milliseconds since the device was turned on.
protected void onFocus(int direction)
FieldThe framework will not invoke this method if this field already has
the focus or is not focusable (Field.isFocusable() returns
false).
Managers should find a child field that accepts focus and trigger this method's call to it.
The direction value indicates how the focus came to enter the field:
onFocus in class Fielddirection - The direction from which the focus enters the
field.protected void onUnfocus()
FieldThe method will not be invoked if this field does not already have the focus.
By default, this method clears the muddy bit and removes selection. If your custom field requires special handling upon losing the focus, you must override this method. Don't forget to call this method on the parent though, or the muddy bit won't get cleared.
onUnfocus in class Fieldprotected void paint(Graphics graphics)
This field's manager invokes this method during the repainting process to instruct this field to repaint itself.
paint in class Fieldgraphics - Graphics context for repainting this field.public void setChecked(boolean checked)
checked - Pass true to check this field's checkbox; false to clear
this field's checkbox.public void setEditable(boolean editable)
This method lets you change the style of this field by either adding,
or removing, the Field.EDITABLE style.
setEditable in class Fieldeditable - If True, make this field editable; otherwise, make this
field non-editable.public void setLabel(String label)
label - Label string for this field: always appears just to the
right of the checkbox.protected boolean touchEvent(TouchEvent message)
This method handles touch input events. DOWN events cause this CheckboxField to enter a focused state, which is in fact handled at the Manager level. UNCLICK events on the field toggle the checkbox. The remaining touch input events are consumed and/or ignored.
touchEvent in class Fieldmessage - TouchEvent object containing various input parameters
including the event type and touch coordinates.
IllegalArgumentException - If message is null.public String toString()
toString in class Object
protected boolean trackwheelClick(int status,
int time)
The system invokes this method when passing on a trackwheel click event.
The ALT-click combination will enter selection mode, or if in selection mode will copy.
trackwheelClick in class Fieldstatus - Bitfield of values defined by Keypad.time - Number of milliseconds since the device was turned on.
protected boolean trackwheelUnclick(int status,
int time)
The system invokes this method when passing on a trackwheel release event.
trackwheelUnclick in class Fieldstatus - Bitfield of values defined by Keypad.time - Number of milliseconds since the device was turned on.
public AccessibleContext getAccessibleContext()
getAccessibleContext in class Fieldpublic void getFocusRect(XYRect rect)
FieldThe framework uses this method to retrieve the current focus region for this field, in field-local coordinates; that is, the region that is made visible by the framework (by scrolling) when the field has the focus.
By default, the focus region is the same as the field's entire extent, in content coordinates.
getFocusRect in class Fieldrect - The object to contain the focus region for this field in local
coordinates.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
Copyright 1999-2011 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Java is a trademark of Oracle America Inc. in the US and other countries.
Legal