📄 telephonelistmidlet.java
字号:
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import java.io.IOException;
public class TelephoneListMIDlet extends MIDlet implements CommandListener
{
static TelephoneListMIDlet instance;
private Display display;
private Form mainScreen;
private Command exitCommand, addCommand, editCommand,
deleteCommand, deleteStoreCommand;
public static PersistantData pd;
public TelephoneListMIDlet() throws IOException
{
this.instance = this;
pd = new PersistantData();
pd.openRecStore("Telephone Directory");
exitCommand = (new Command("Exit", Command.EXIT, 0));
addCommand = new Command("Add to Telephone List", Command.SCREEN, 0);
editCommand = new Command("Edit Telephone List", Command.SCREEN, 1);
deleteCommand = new Command("Delete from Telephone List", Command.SCREEN, 2);
deleteStoreCommand = new Command("Delete record Store", Command.SCREEN, 3);
mainScreen = new Form("FlagMidlet");
mainScreen.append("Hit the menu button to see the choices");
mainScreen.addCommand(exitCommand);
mainScreen.addCommand(addCommand);
mainScreen.addCommand(editCommand);
mainScreen.addCommand(deleteCommand);
mainScreen.addCommand(deleteStoreCommand);
mainScreen.setCommandListener(this);
display = Display.getDisplay(this);
}
public Form getForm()
{
return mainScreen;
}
public void commandAction(Command c, Displayable d)
{
if (c == exitCommand)
{
TelephoneListMIDlet.quitApp();
}
else if (c == addCommand)
{
display.setCurrent(new AddScreen());
}
else if (c == editCommand)
{
display.setCurrent(new EditScreen());
}
else if (c == deleteCommand)
{
display.setCurrent(new DeleteScreen());
}
else if (c == deleteStoreCommand)
{
try
{
PersistantData.recordStore.closeRecordStore();
System.out.println("record store closed");
PersistantData.recordStore.deleteRecordStore("Telephone Directory");
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
public void startApp()
{
display.setCurrent(mainScreen);
}
public void pauseApp()
{
}
public void destroyApp(boolean unconditional)
{
instance.destroyApp(true);
instance.notifyDestroyed();
instance = null;
System.out.println("finished");
}
public static void quitApp()
{
instance.destroyApp(true);
instance.notifyDestroyed();
instance = null;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -