deletescreen.java

来自「java 的手机通讯录程序」· Java 代码 · 共 49 行

JAVA
49
字号
import javax.microedition.lcdui.*;
import java.io.IOException;

public class DeleteScreen extends Form implements CommandListener
{
  private Command deleteCommand, backCommand;
  private ChoiceGroup recStore;
  private String[] table;
  private int selection;

  public DeleteScreen()
  {
    super("Delete Screen");
    try
    {
      deleteCommand = new Command("Delete", Command.OK, 0);
      backCommand = (new Command("Back", Command.BACK, 1));
      addCommand(deleteCommand);
      addCommand(backCommand);
      setCommandListener(this);
      table = TelephoneListMIDlet.pd.readRecordStore();
      recStore = new ChoiceGroup("", ChoiceGroup.EXCLUSIVE, table, null);
      append("select the record you want to delete by using the up an down arrows and then pressing SELECT");
      append("press the delete button to delete the record");
      append(recStore);

    }
    catch (Exception e)
    {
      e.printStackTrace();
    }
  }

  public void commandAction(Command c, Displayable d)
  {
    if (c == deleteCommand)
    {
      selection = recStore.getSelectedIndex();
      String recordno = TelephoneListMIDlet.pd.getRecno(table[selection]);
      TelephoneListMIDlet.pd.deleteRecord(Integer.parseInt(recordno));
    }
    else if (c == backCommand)
    {
      Display.getDisplay(TelephoneListMIDlet.instance).setCurrent(
          TelephoneListMIDlet.instance.getForm());
    }
  }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?