代码
/**
* 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);
}
}
Java Asp PHP .Net XML C/C++ CGI VB Jsp J2ee J2se J2me EJB Servlet Tomcat Resin Struts Weblogic Eclipse ANT GUI JMS Web servise IDEA Webphere Hibernate Spring Jboss Applet Swing Socket Javamail Perl Ajax P2P 安全 模式 框架 测试 开源 游戏
Windows XP Windows 2000 Windows 2003 Windows Me Windows 9.x Linux UNIX 注册表 操作系统 服务器 应用服务器