📄 mailmidlet.java
字号:
package PhoneBook;
import javax.microedition.lcdui.*;
import javax.microedition.midlet.MIDlet;
import javax.microedition.rms.RecordStore;
public class MailMIDlet 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 MailMIDlet(){
display=Display.getDisplay(this);
}
protected void startApp(){
Image[] imageArray=null;
try{
Image icon=Image.createImage("/girl.png");
imageArray=new Image[]{icon,icon,icon,icon};
}catch(java.io.IOException err){
imageArray=null;
}
String[] stringArray={"添加新记录","浏览电话簿","查找记录","删除记录"};
mainList=new List("电话簿",Choice.IMPLICIT,stringArray,imageArray);
mainList.addCommand(exitCommand);
mainList.addCommand(confirmCommand);
mainList.setCommandListener(this);
display.setCurrent(mainList);
try{
rs=RecordStore.openRecordStore("MyPhoneBook",true);
}catch(Exception e){
rs=null;
}
}
protected void destroyApp(boolean unconditional){
}
protected void pauseApp(){
}
public void commandAction(Command c,Displayable d){
if(d.equals(mainList)){
if(c==List.SELECT_COMMAND|| c==confirmCommand){
if(d.equals(mainList)){
switch(((List)d).getSelectedIndex()){
case 0:
NewRecordForm newRF=new NewRecordForm(BookConstant.record_added,mainList,this,rs);
display.setCurrent(newRF);
break;
case 1:
ListRecord list=new ListRecord(BookConstant.listPhoneTitle,Choice.IMPLICIT,mainList,this,rs);
display.setCurrent(list);
break;
case 2:
FindRecord fr=new FindRecord(mainList,this,rs);
display.setCurrent(fr);
break;
case 3:
DeleteRecord dr=new DeleteRecord(mainList,this,rs);
display.setCurrent(dr);
break;
}
}
}
}
if(c==exitCommand){
try{
rs.closeRecordStore();
rs=null;
}catch(Exception e){
}
destroyApp(false);
notifyDestroyed();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -