国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發(fā)設計 > 正文

關于在canvas類里調用textbox

2019-11-18 15:08:13
字體:
來源:轉載
供稿:網(wǎng)友

  代碼:--------------------------------------------------------------------------------
/**
* TextBox´´s instance
*/
PRivate TextBox inputName = null;

/**
* 「cancel」Command
* command in TextBox
*/
private Command cCancel = new Command("cancel", Command.CANCEL, 1);

/**
* 「ok」Command
* command in TextBox
*/
private Command cOK = new Command("ok", Command.OK, 1);

/**
* 保存在TextBox中已輸入的值
*/
private String name = "";

/**
* 調用TextBox
* The method disposes the key pressing action
* the code of pressed key
* @param key
*/
public void keyPressed(int key) {
if (key == Canvas.FIRE) {
inputName = new TextBox("請輸入姓名", name, 8, TextField.ANY);
inputName.addCommand(cCancel);
inputName.addCommand(cOK);
inputName.setCommandListener(this);
Display.getDisplay(BustRoyal.instance).setCurrent(inputName);
//其中BustRoyal.instance為MIDlet的實例
}
}

/**
* TextBox中的command的處理
*/
public void commandAction(Command c, Displayable d) {
if (c == cCancel) {
Display.getDisplay(BustRoyal.instance).setCurrent(this);
} else if (c == cOK) {
name = inputName.getString().trim();
Display.getDisplay(BustRoyal.instance).setCurrent(this);
}
}

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 正蓝旗| 麟游县| 长兴县| 元谋县| 麟游县| 龙海市| 弥勒县| 富平县| 专栏| 清水县| 三原县| 信宜市| 那坡县| 齐河县| 华宁县| 南丹县| 邮箱| 宝清县| 六盘水市| 旺苍县| 客服| 佳木斯市| 江城| 栖霞市| 华宁县| 潍坊市| 牙克石市| 台东县| 贡嘎县| 南江县| 淮滨县| 绥化市| 星座| 包头市| 和硕县| 铅山县| 宝兴县| 新建县| 常山县| 图们市| 颍上县|