editform.java
来自「J2ME 浏览文件功能」· Java 代码 · 共 48 行
JAVA
48 行
import javax.microedition.lcdui.*;
import java.io.IOException;
public class EditForm extends Form implements CommandListener{
ClientMIDlet midlet;
Command cmdOK = new Command("发送",Command.OK,1);
Command cmdFile = new Command("选择文件",Command.OK,2);
Command cmdExit = new Command("退出",Command.EXIT,3);
TextField txtAddr = new TextField("收信人", "13027974967", 20, TextField.NUMERIC);
TextField txtContent = new TextField("内容", "测试内容测试内容测试内容", 200, TextField.ANY);
StringItem siPath = new StringItem("文件路径", "file:///root1/Readme");
public EditForm(ClientMIDlet m) {
super("短信编辑");
midlet = m;
this.append(txtAddr);
this.append(txtContent);
txtContent.setPreferredSize(this.getWidth(), this.getHeight()-txtAddr.getPreferredHeight()-siPath.getPreferredHeight()-20);
this.append(siPath);
addCommand(cmdOK);
addCommand(cmdExit);
addCommand(cmdFile);
setCommandListener(this);
}
public void commandAction(Command cmd,Displayable dis){
if(cmd.equals(cmdFile)){
midlet.fb.showDir();
midlet.display.setCurrent(midlet.fb);
}else if(cmd.equals(cmdOK)){
if(txtAddr.getString().length()==0){
Alert alert = new Alert("错误", "您还没有输入收件人号码!", null, AlertType.ERROR);
alert.setTimeout(2000);
midlet.display.setCurrent(alert, this);
} else {
//准备发送
}
}else if(cmd.equals(cmdExit)){
midlet.destroyApp(true);
}
}
public void setPath(){
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?