textfielddemo.java
来自「《精通JAVA手机游戏与应用程序设计》随书光盘」· Java 代码 · 共 51 行
JAVA
51 行
/*
* @(#)TextFieldDemo.java 1.7 04/04/25
*
* Copyright (c) 2000-2004 Sun Microsystems, Inc. All rights reserved.
* PROPRIETARY/CONFIDENTIAL Use is subject to license terms
*/
import javax.microedition.midlet.MIDlet;
import javax.microedition.lcdui.*;
public class TextFieldDemo extends MIDlet implements CommandListener {
private Command exitCommand = new Command("退出", Command.EXIT, 1);
private Form mainForm;
public TextFieldDemo() {
mainForm = new Form("Text Field");
}
protected void startApp() {
mainForm.append("显示各种类型的TextField");
mainForm.append(new TextField("任何字符", "", 15, TextField.ANY));
mainForm.append(new TextField("E-Mail", "", 15, TextField.EMAILADDR));
mainForm.append(new TextField("数字", "", 15, TextField.NUMERIC));
mainForm.append(new TextField("浮点数", "", 15, TextField.DECIMAL));
mainForm.append(new TextField("电话", "", 15, TextField.PHONENUMBER));
mainForm.append(new TextField("密码", "", 15, TextField.PASSWORD));
mainForm.append(new TextField("网址URL", "", 15, TextField.URL));
mainForm.addCommand(exitCommand);
mainForm.setCommandListener(this);
Display.getDisplay(this).setCurrent(mainForm);
}
public void commandAction(Command c, Displayable s) {
if (c == exitCommand) {
destroyApp(false);
notifyDestroyed();
}
}
protected void destroyApp(boolean unconditional) {
}
protected void pauseApp() {
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?