- wuhua
- 等级:
- 性别:
- 文章: 634
- 积分: 1688
- 来自: 广州
|
艾,不想解释了。贴代码算了
java 代码
-
-
-
-
-
- package org.pook.ui;
-
- import javax.microedition.lcdui.Graphics;
- import javax.microedition.lcdui.Image;
-
- import org.pook.ui.core.Platform;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- public class Choice extends Part {
-
-
- private boolean select;
-
-
- private Image[] imageElements;
-
-
-
- public Choice(String label,
- Image[] imageElements, boolean select) {
- super(0, 0, 0, 0);
- if(label == null)
- label = "";
- this.label = label;
- this.select = select;
- this.imageElements = imageElements;
-
- }
-
-
- public void paint(Graphics g) {
- paintChoiceImpl(g);
-
- }
-
- private void paintChoiceImpl(Graphics g) {
-
- paintChoice(g);
-
- }
-
-
-
- private void paintChoice(Graphics g) {
- g.drawImage(select?imageElements[0]:imageElements[1],view[X], view[Y],
- Graphics.TOP|Graphics.LEFT);
- paintLabel(g);
-
- }
- private void paintLabel(Graphics g) {
- if(label.equals(""))
- return;
- g.setColor(fontColor);
- g.drawString(label,view[X] + imageElements[0].getWidth() + 4, view[Y]-2, Graphics.TOP | Graphics.LEFT);
-
- if(hasFocus)
- paintSelect(g);
- }
-
-
-
-
- private void paintSelect(Graphics g) {
- g.drawRect(view[X] - 1, view[Y] - 1,
- imageElements[0].getWidth() + 1,
- imageElements[0].getHeight() + 1);
-
-
- }
-
-
- public void onClick(int keyCode) {
- if(keyCode == Platform.KEY_ENTER
- && hasFocus)
- select = !select;
-
- }
-
-
- public boolean isSelect() {
- return select;
- }
-
-
- public void setSelect(boolean select) {
- this.select = select;
- }
-
- }
声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
|
返回顶楼 |
|
|
- linginfanta
- 等级: 初级会员
- 性别:
- 文章: 201
- 积分: 40
- 来自: 深圳
|
代码不全
|
返回顶楼 |
|
|