Java Reference
In-Depth Information
textBox.setTitle ("Diary - Day " + currentId);
}
catch (RecordStoreException e) {
throw new RuntimeException ("Cannot perform; reason: "+e);
}
}
}
Listing 5.2 RmsDemoPdap.java —The Diary Application for PDAP
import java.awt.*;
import java.awt.event.*;
import javax.microedition.rms.*;
import javax.microedition.midlet.*;
public class RmsDemoPdap extends MIDlet implements ActionListener {
Frame frame = new Frame();
TextArea textArea = new TextArea();
int currentId;
RecordStore diary;
Button buttonPrev = new Button ("Prev");
Button buttonNext = new Button ("Next");
Button buttonNew = new Button ("New");
public RmsDemoPdap() {
try {
diary = RecordStore.openRecordStore ("diary", true);
String text = loadEntry (diary.getNumRecords());
textArea.setText (text);
frame.setTitle ("Diary - Day " + currentId);
}
catch (RecordStoreException e) {
throw new RuntimeException ("Cannot open diary; reason:
"+e);
}
frame.add("Center", textArea);
Panel buttons = new Panel();
buttons.add(buttonPrev);
buttons.add(buttonNext);
buttons.add(buttonNew);
buttonPrev.addActionListener(this);
buttonNext.addActionListener(this);
buttonNew.addActionListener(this);
frame.add("South", buttons);
frame.pack();
frame.addWindowListener(new WindowAdapter() {
public void windowClosing (WindowEvent ev) {
destroyApp (true);
notifyDestroyed();
}
});
}
 
Search WWH ::




Custom Search