📄 textfielddemo.java
字号:
//TextFieldDemo.java
import javax.microedition.midlet.MIDlet;
import javax.microedition.lcdui.*;
public class TextFieldDemo
extends MIDlet implements CommandListener {
private Command exitCommand = new Command("Exit", Command.EXIT, 1);
protected void startApp() {
Form f = new Form("Text Field");
f.append("This demo contains text fields each one " +
"with a different constraint");
f.append(new TextField
("Any Character", "English", 15, TextField.ANY));
f.append(new TextField
("E-Mail", "woo@yahoo.com", 15, TextField.EMAILADDR));
f.append(new TextField
("Number", "9876", 15, TextField.NUMERIC));
f.append(new TextField
("Decimal", "12.34", 15, TextField.DECIMAL));
f.append(new TextField
("Phone", "086010762768899", 20, TextField.PHONENUMBER));
f.append(new TextField
("Password", "pwdandpwd", 15, TextField.PASSWORD));
f.append(new TextField
("URL", "http://www.pku.edu.cn", 25, TextField.URL));
f.addCommand(exitCommand);
f.setCommandListener(this);
Display.getDisplay(this).setCurrent(f);
}
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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -