mainmidlet.java
来自「J2ME下一个还算简单的电话本功能代码 测试通过 可以运行」· Java 代码 · 共 67 行
JAVA
67 行
import javax.microedition.lcdui.Choice;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.List;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;
import javax.microedition.rms.RecordStore;
public class MainMIDlet extends MIDlet implements CommandListener {
private final static Command exitCommand = new Command("推出", Command.EXIT,
1);
private final static Command confirmCommand = new Command("确认",
Command.SCREEN, 1);
private Display display;
private List mainList;
private RecordStore rs;
public MainMIDlet() {
super();
display = this.display.getDisplay(this);
// TODO Auto-generated constructor stub
}
protected void startApp() throws MIDletStateChangeException {
Image[] imageArray = null;
try {
Image icon = Image.createImage("/pic/choose.png");
imageArray = new Image[] { icon, icon, icon, icon };
} catch (java.io.IOException e) {
imageArray = null;
}
String[] StringArray ={"添加新记录","浏览电话薄","查找记录","删除记录"};
mainList = new List("电话本",Choice.IMPLICIT,StringArray,imageArray);
mainList.addCommand(exitCommand);
mainList.addCommand(confirmCommand);
mainList.setCommandListener(this);
display.setCurrent(mainList);
}
protected void pauseApp() {
// TODO Auto-generated method stub
}
protected void destroyApp(boolean arg0) throws MIDletStateChangeException {
// TODO Auto-generated method stub
}
public void commandAction(Command arg0, Displayable arg1) {
// TODO Auto-generated method stub
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?