jMobileCore toolkit

com.jmobilecore.ui.core
Class Checkbox

java.lang.Object
  extended by com.jmobilecore.ui.core.Component
      extended by com.jmobilecore.ui.core.Label
          extended by com.jmobilecore.ui.core.Checkbox

public class Checkbox
extends Label

A check box is a graphical component that can be in either an "on" (true) or "off" (false) state. Clicking on a check box changes its state from "on" to "off," or from "off" to "on."

Author:
Greg Gridin

Field Summary
 CheckboxGroup group
          The check box group.
 boolean state
          The state of the Checkbox.
 
Fields inherited from class com.jmobilecore.ui.core.Label
text
 
Fields inherited from class com.jmobilecore.ui.core.Component
alignment, background, CENTER, focusable, focusedBackground, focusedForeground, font, foreground, height, isCompletelyVisible, isFocused, isVisible, LEFT, parentScreen, RIGHT, screenY, valid, width
 
Constructor Summary
Checkbox(java.lang.String label, boolean state)
          Creates a check box with the specified label and sets the specified state.
Checkbox(java.lang.String label, javax.microedition.lcdui.Font font, boolean state)
          Creates a check box with the specified label and sets the specified state.
Checkbox(java.lang.String label, javax.microedition.lcdui.Font font, boolean state, CheckboxGroup group)
          Constructs a Checkbox with the specified label, set to the specified state, and in the specified check box group.
 
Method Summary
 boolean keyPressed(int keyCode)
          Responds to key presses when the button has focus.
 void paint(javax.microedition.lcdui.Graphics g)
          Paints the checkbox to the screen.
 void setCheckboxGroup(CheckboxGroup g)
          Sets this check box's group to be the specified check box group.
 void setState(boolean state)
          Sets the state of this check box to the specified state.
 
Methods inherited from class com.jmobilecore.ui.core.Label
createTitleLabel, getText, setText
 
Methods inherited from class com.jmobilecore.ui.core.Component
destructor, getBackground, getFont, getForeground, getHeight, getWidth, invalidate, isFocusOwner, keyReleased, keyRepeated, paintBackground, pointerDragged, pointerPressed, pointerReleased, prepareForeground, releaseFocus, requestFocus, setFont, setHeight
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

group

public CheckboxGroup group
The check box group. This field can be null indicating that the checkbox is not a group checkbox.


state

public boolean state
The state of the Checkbox.

Constructor Detail

Checkbox

public Checkbox(java.lang.String label,
                boolean state)
Creates a check box with the specified label and sets the specified state.

Parameters:
label - a string label for this check box, or null for no label
state - the initial state of this check box

Checkbox

public Checkbox(java.lang.String label,
                javax.microedition.lcdui.Font font,
                boolean state)
Creates a check box with the specified label and sets the specified state.

Parameters:
label - a string label for this check box, or null for no label
state - the initial state of this check box

Checkbox

public Checkbox(java.lang.String label,
                javax.microedition.lcdui.Font font,
                boolean state,
                CheckboxGroup group)
Constructs a Checkbox with the specified label, set to the specified state, and in the specified check box group.

Parameters:
label - a string label for this check box, or null for no label.
state - the initial state of this check box.
group - a check box group for this check box, or null for no group.
Method Detail

keyPressed

public boolean keyPressed(int keyCode)
Responds to key presses when the button has focus.

Overrides:
keyPressed in class Component
Parameters:
keyCode - The pressed key.

paint

public void paint(javax.microedition.lcdui.Graphics g)
Paints the checkbox to the screen.

Overrides:
paint in class Label
Parameters:
g - The Graphics object

setCheckboxGroup

public void setCheckboxGroup(CheckboxGroup g)
Sets this check box's group to be the specified check box group. If this check box is already in a different check box group, it is first taken out of that group. If the state of this check box is true and the new group already has a check box selected, this check box's state is changed to false.

Parameters:
g - the new check box group, or null to remove this check box from any check box group.

setState

public void setState(boolean state)
Sets the state of this check box to the specified state. The boolean value true indicates the "on" state, and false indicates the "off" state.

Parameters:
state - the boolean state of the check box

jMobileCore toolkit