|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object
|
+--net.rim.device.api.ui.Field
|
+--net.rim.device.api.ui.component.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.
Pressing the spacebar when a checkbox field has the focus toggles its state.
| Field Summary |
| Fields inherited from class net.rim.device.api.ui.Field |
EDITABLE, EDITABLE_MASK, FIELD_BOTTOM, FIELD_HALIGN_MASK, FIELD_HCENTER, FIELD_LEFT, FIELD_RIGHT, FIELD_TOP, FIELD_VALIGN_MASK, FIELD_VCENTER, FOCUSABLE, FOCUSABLE_MASK, HIGHLIGHT_FOCUS, HIGHLIGHT_SELECT, NON_FOCUSABLE, READONLY, USE_ALL_HEIGHT, USE_ALL_WIDTH |
| 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 indicator for this field. |
|
boolean |
getChecked()
Retrieves this field's state. |
|
void |
getFocusRect(XYRect rect)
Retrieves the focus region for this field. |
|
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 |
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 |
paint(Graphics graphics)
Redraws this field. |
|
void |
setChecked(boolean checked)
Sets the state of this field. |
|
void |
setLabel(String label)
Sets this field's label. |
|
| Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
| Constructor Detail |
public CheckboxField()
This builds an unchecked checkbox field with no label.
public CheckboxField(String label, boolean checked)
This builds a checkbox field with the Field.EDITABLE and
Field.FOCUSABLE styles.
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.
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)
A field's manager invokes this method after painting the field. The
manager initializes the graphics object passed in for drawing with
field-local coordinates. It is also assumed that the region is already
drawn correctly with the opposing state for the on
parameter.
When overriding this methods fields should use
Field.drawHighlightRegion(net.rim.device.api.ui.Graphics, int, boolean, int, int, int, int) to render focus and select regions instead
of hardcoding the logic.
By default, this method invokes Field.drawHighlightRegion(net.rim.device.api.ui.Graphics, int, boolean, int, int, int, int) to
render the focus indicator using the rect obtained from
getFocusRect(net.rim.device.api.ui.XYRect).
graphics - Graphics context for this field.on - True if the focus should be set; otherwise, false.public boolean getChecked()
public void getFocusRect(XYRect rect)
This method retrieves the focus region as the width of a checked check box. Only the checkbox portion of this field ever receives the focus.
getFocusRect in class Fieldrect - To contain the local coordinates of the focus rect.public String getLabel()
public int getPreferredHeight()
Managers may make use of this value during layout.
getPreferredHeight in class Fieldpublic int getPreferredWidth()
Managers make use of this value during layout.
getPreferredWidth in class Field
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).
key - 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 Charm device) that's generated; otherwise, this method does nothing and does not consume the event.
keycode - 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 avilable space.
width - Amount of available horizontal space.height - Amount of available vertical space.protected void makeContextMenu(ContextMenu contextMenu)
Field.getContextMenu() to invoke this method to
construct this field's context menu. You shouldn't invoke this method
directly.
If the UI is not operating in MODE_ADVANCD mode
(and this field is Field.EDITABLE), this method builds this field's
context menu adding a menu item for changing this field's value.makeContextMenu in class FieldcontextMenu - Context menu to create.
protected int moveFocus(int amount,
int status,
int time)
This field's maanager invokes this method only when this field
already ahs 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.
amount - 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.public void setChecked(boolean checked)
checked - Pass true to check this field's checkbox; false to clear
this field's checkbox.public void setLabel(String label)
label - Label string for this field: always appears just to the
right of the checkbox.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
Copyright 1999-2004 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Copyright 1993-2003 Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
Copyright 2002-2003 Nokia Corporation All Rights Reserved.
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.