home *** CD-ROM | disk | FTP | other *** search
/ All for Cell Phones: Sony Ericsson / Sony-Ericsson 2004.iso / Java / Memory / Memory.jar / MemoryGame / MemoryMIDlet.class (.txt) < prev   
Encoding:
Java Class File  |  2002-01-04  |  2.5 KB  |  69 lines

  1. package MemoryGame;
  2.  
  3. import javax.microedition.lcdui.Command;
  4. import javax.microedition.lcdui.CommandListener;
  5. import javax.microedition.lcdui.Display;
  6. import javax.microedition.lcdui.Displayable;
  7. import javax.microedition.lcdui.Form;
  8. import javax.microedition.lcdui.TextField;
  9. import javax.microedition.midlet.MIDlet;
  10. import javax.microedition.midlet.MIDletStateChangeException;
  11.  
  12. public class MemoryMIDlet extends MIDlet implements CommandListener {
  13.    public static Form scoreForm;
  14.    public static TextField _scoreField;
  15.    public static Command _doneCommand;
  16.    public static Displayable _currentDisplayable;
  17.    public static boolean HiScoreOk;
  18.    private MemoryCanvas canvas;
  19.    private static Display display;
  20.    private static Command _exitCommand = new Command("Exit", 7, 1);
  21.  
  22.    public void startApp() throws MIDletStateChangeException {
  23.       display = Display.getDisplay(this);
  24.       this.canvas = new MemoryCanvas(display);
  25.       this.canvas.addCommand(_exitCommand);
  26.       this.canvas.setCommandListener(this);
  27.       display.setCurrent(this.canvas);
  28.       scoreForm = new Form("HighScore!");
  29.       _scoreField = new TextField("Your name 3 initials", "", 3, 0);
  30.       scoreForm.append(_scoreField);
  31.       _doneCommand = new Command("Done", 1, 1);
  32.       scoreForm.addCommand(_doneCommand);
  33.       scoreForm.setCommandListener(this);
  34.    }
  35.  
  36.    public void pauseApp() {
  37.    }
  38.  
  39.    public void destroyApp(boolean var1) {
  40.       ((MIDlet)this).notifyDestroyed();
  41.    }
  42.  
  43.    public void commandAction(Command var1, Displayable var2) {
  44.       if (var1 == _exitCommand) {
  45.          try {
  46.             this.destroyApp(false);
  47.          } catch (Exception var4) {
  48.          }
  49.  
  50.          ((MIDlet)this).notifyDestroyed();
  51.       } else if (var1 == _doneCommand) {
  52.          HiScoreOk = true;
  53.          setDisplayable(this.canvas);
  54.       }
  55.  
  56.    }
  57.  
  58.    public static void enterHighScore() {
  59.       HiScoreOk = false;
  60.       _scoreField.setString("");
  61.       setDisplayable(scoreForm);
  62.    }
  63.  
  64.    public static void setDisplayable(Displayable var0) {
  65.       _currentDisplayable = var0;
  66.       display.setCurrent(var0);
  67.    }
  68. }
  69.