📄 textboxtest.java
字号:
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
public class TextBoxTest extends MIDlet implements CommandListener{
Display display;
TextBox textBox;
Command exitCmd;
Command anyMode;
Command emailMode;
Command numMode;
Command phoneMode;
Command urlMode;
Command passwordCmd;
public TextBoxTest(){
display = Display.getDisplay(this);
textBox = new TextBox("登记个人资料","",20,TextField.URL);
exitCmd = new Command("退出", Command.EXIT, 1);
anyMode = new Command("ANY", Command.SCREEN,1);
emailMode = new Command("EMAILADDR", Command.SCREEN,2);
numMode = new Command("NUMERIC", Command.SCREEN,3);
phoneMode = new Command("PHONENUMER", Command.SCREEN,4);
urlMode = new Command("URL", Command.SCREEN,5);
passwordCmd = new Command("PASSWORD", Command.SCREEN,6);
textBox.addCommand(exitCmd);
textBox.addCommand(anyMode);
textBox.addCommand(emailMode);
textBox.addCommand(numMode);
textBox.addCommand(phoneMode);
textBox.addCommand(urlMode);
textBox.addCommand(passwordCmd);
textBox.setCommandListener(this);
}
public void startApp(){
display.setCurrent(textBox);
}
public void pauseApp(){
}
public void destroyApp(boolean unconditional){
}
public void commandAction(Command c, Displayable d){
if(c == exitCmd){
destroyApp(false);
notifyDestroyed();
}
else if(c == anyMode){
textBox.delete(0,textBox.size());
textBox.setConstraints(TextField.ANY);
System.out.println("mode"+textBox.getConstraints());
}
else if(c == emailMode){
textBox.delete(0,textBox.size());
textBox.setConstraints(TextField.EMAILADDR);
System.out.println("mode"+textBox.getConstraints());
}
else if(c == numMode){
textBox.delete(0,textBox.size());
textBox.setConstraints(TextField.NUMERIC);
System.out.println("mode"+textBox.getConstraints());
}
else if(c == phoneMode){
textBox.delete(0,textBox.size());
textBox.setConstraints(TextField.PHONENUMBER);
System.out.println("mode"+textBox.getConstraints());
}
else if(c == urlMode){
textBox.delete(0,textBox.size());
textBox.setConstraints(TextField.URL);
System.out.println("mode"+textBox.getConstraints());
}
else if(c == passwordCmd){
textBox.delete(0,textBox.size());
textBox.setConstraints(TextField.PASSWORD | textBox.getConstraints());
System.out.println("mode"+textBox.getConstraints());
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -