?? simplecheckbox.java
字號:
package com.jmobilecore.ui.core;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Font;
/**
* A check box is a graphical component that can be in either an
* "on" (<code>true</code>) or "off" (<code>false</code>) state.
* Clicking on a check box changes its state from
* "on" to "off," or from "off" to "on."
* This object cannot be included into <code>CheckboxGroup</code> object
*
* @author Greg Gridin
*/
public class SimpleCheckbox extends Label {
/**
* The state of the <code>Checkbox</code>.
*/
public boolean state;
/**
* Creates a check box with the specified label
* and sets the specified state.
*
* @param label a string label for this check box,
* or <code>null</code> for no label
* @param state the initial state of this check box
*/
public SimpleCheckbox(String label, boolean state) {
this(label, Style.TEXT_FONT, state);
}
/**
* Creates a check box with the specified label
* and sets the specified state.
*
* @param label a string label for this check box,
* or <code>null</code> for no label
* @param state the initial state of this check box
*/
public SimpleCheckbox(String label, Font font, boolean state) {
super(label, font, Label.LEFT);
this.state = state;
focusable = true;
}
/**
* Paints the checkbox to the screen.
*
* @param g The Graphics object
*/
public void paint(Graphics g) {
super.paint(g);
int y = screenY + Style.V_GAP;
final int sideSize = getHeight() - 3;
int x;
if (alignment == LEFT || alignment == CENTER ) {
x = getWidth()- sideSize - 1 - Style.H_GAP;
} else /*if (alignment == RIGHT)*/ {
x = Style.H_GAP;
}
g.drawRect(x, y, sideSize, sideSize);
if (state) {
g.drawLine(x, y, x + sideSize - 1, y + sideSize - 1);
g.drawLine(x + sideSize, y, x, y + sideSize);
}
}
/**
* Responds to key presses when the button has focus.
*
* @param keyCode The pressed key.
*/
public boolean keyPressed(int keyCode) {
if (keyCode == PlatformCanvas.KEY_ENTER) {
state = !state;
parentScreen.repaint();
return true;
}
return super.keyPressed(keyCode);
}
} // class Checkbox
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -