home *** CD-ROM | disk | FTP | other *** search
- package MemoryGame;
-
- import javax.microedition.lcdui.Command;
- import javax.microedition.lcdui.CommandListener;
- import javax.microedition.lcdui.Display;
- import javax.microedition.lcdui.Displayable;
- import javax.microedition.lcdui.Form;
- import javax.microedition.lcdui.TextField;
- import javax.microedition.midlet.MIDlet;
- import javax.microedition.midlet.MIDletStateChangeException;
-
- public class MemoryMIDlet extends MIDlet implements CommandListener {
- public static Form scoreForm;
- public static TextField _scoreField;
- public static Command _doneCommand;
- public static Displayable _currentDisplayable;
- public static boolean HiScoreOk;
- private MemoryCanvas canvas;
- private static Display display;
- private static Command _exitCommand = new Command("Exit", 7, 1);
-
- public void startApp() throws MIDletStateChangeException {
- display = Display.getDisplay(this);
- this.canvas = new MemoryCanvas(display);
- this.canvas.addCommand(_exitCommand);
- this.canvas.setCommandListener(this);
- display.setCurrent(this.canvas);
- scoreForm = new Form("HighScore!");
- _scoreField = new TextField("Your name 3 initials", "", 3, 0);
- scoreForm.append(_scoreField);
- _doneCommand = new Command("Done", 1, 1);
- scoreForm.addCommand(_doneCommand);
- scoreForm.setCommandListener(this);
- }
-
- public void pauseApp() {
- }
-
- public void destroyApp(boolean var1) {
- ((MIDlet)this).notifyDestroyed();
- }
-
- public void commandAction(Command var1, Displayable var2) {
- if (var1 == _exitCommand) {
- try {
- this.destroyApp(false);
- } catch (Exception var4) {
- }
-
- ((MIDlet)this).notifyDestroyed();
- } else if (var1 == _doneCommand) {
- HiScoreOk = true;
- setDisplayable(this.canvas);
- }
-
- }
-
- public static void enterHighScore() {
- HiScoreOk = false;
- _scoreField.setString("");
- setDisplayable(scoreForm);
- }
-
- public static void setDisplayable(Displayable var0) {
- _currentDisplayable = var0;
- display.setCurrent(var0);
- }
- }
-