📄 listrecord.java
字号:
/* * To change this template, choose Tools | Templates * and open the template in the editor. */package org.challenge.chengshi.record;import javax.microedition.lcdui.Command;import javax.microedition.lcdui.CommandListener;import javax.microedition.lcdui.Display;import javax.microedition.lcdui.Displayable;import javax.microedition.lcdui.List;import javax.microedition.rms.InvalidRecordIDException;import javax.microedition.rms.RecordEnumeration;import javax.microedition.rms.RecordStoreException;import javax.microedition.rms.RecordStoreNotOpenException;import org.challenge.chengshi.MainMidlet;/** * * 列表显示游戏的记录 * @author challenge */public class ListRecord extends List implements CommandListener { MainMidlet mid; Command back=new Command("返回",Command.BACK,1); Record record; public ListRecord(MainMidlet mid){ super("记录列表",List.IMPLICIT); this.mid=mid; init(); this.addCommand(back); this.setCommandListener(this); } //初始化 private void init(){ this.record=new Record(); RecordEnumeration em=this.record.getRecord(); if(em!=null&&em.numRecords()>0){ while(em.hasNextElement()){ try { this.append(new String(em.nextRecord()), null); } catch (InvalidRecordIDException ex) { ex.printStackTrace(); } catch (RecordStoreNotOpenException ex) { ex.printStackTrace(); } catch (RecordStoreException ex) { ex.printStackTrace(); } } }else{ this.append("暂无记录", null); } show(); } private void show(){ Display.getDisplay(this.mid).setCurrent(this); } public void commandAction(Command cmd, Displayable display) { if(cmd==this.back){ this.mid.show(); } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -