midlet3.java
来自「这是郭克华老师的J2ME视频的源代码」· Java 代码 · 共 61 行
JAVA
61 行
package prj3_1;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Form;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;
public class MIDlet3 extends MIDlet implements CommandListener{
private Form frm = new Form("请您选择相应操作");
private Display dis;
private Command cmdDel = new Command("删除该号码",Command.SCREEN,1);
private Command cmdEdit = new Command("编辑该号码",Command.SCREEN,1);
private Command cmdExit = new Command("退出程序",Command.SCREEN,1);
private Command cmdBack = new Command("返回",Command.BACK,1);
public MIDlet3() {
// TODO Auto-generated constructor stub
}
protected void startApp() throws MIDletStateChangeException {
// TODO Auto-generated method stub
dis = Display.getDisplay(this);
dis.setCurrent(frm);
frm.addCommand(cmdDel);
frm.addCommand(cmdEdit);
frm.addCommand(cmdExit);
frm.addCommand(cmdBack);
frm.setCommandListener(this);
}
public void commandAction(Command c,Displayable d){
if(c==cmdDel || c==cmdEdit){
frm.append(c.getLabel());
}
else if(c==cmdExit){
this.notifyDestroyed();
}
else{
frm.setTitle("返回");
}
/*另一种方法
if(c.getLabel().equals("删除该号码")){
}.....
*/
}
protected void destroyApp(boolean arg0) throws MIDletStateChangeException {
// TODO Auto-generated method stub
}
protected void pauseApp() {
// TODO Auto-generated method stub
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?