Java Reference
In-Depth Information
Figure 5.3. The running RmsDemoPdap application.
Listing 5.1 RmsDemoMidp.java —The Diary Application for MIDP
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import javax.microedition.rms.*;
public class RmsDemoMidp extends MIDlet implements CommandListener {
TextBox textBox = new TextBox ("Diary", "", 150, TextField.ANY);
int currentId = 1;
RecordStore diary;
Display display;
static final Command prevCommand = new Command ("Prev",
Command.SCREEN, 1);
static final Command nextCommand = new Command ("Next",
Command.SCREEN, 2);
static final Command newCommand = new Command ("New",
Command.SCREEN, 3);
public RmsDemoMidp() {
try {
diary = RecordStore.openRecordStore ("diary", true);
String text = loadEntry (diary.getNumRecords());
textBox.setString (text);
textBox.setTitle ("Diary - Day " + currentId);
}
catch (RecordStoreException e) {
throw new RuntimeException ("Cannot open diary; reason:
"+e);
}
 
 
Search WWH ::




Custom Search