FiveMIDlet.java
资源名称:J2ME&Game.rar [点击查看]
上传用户:gyyuli
上传日期:2013-07-09
资源大小:3050k
文件大小:3k
源码类别:
J2ME
开发平台:
Java
- import java.io.IOException;
- import javax.microedition.lcdui.*;
- import javax.microedition.midlet.MIDlet;
- public class FiveMIDlet extends MIDlet
- implements CommandListener
- {
- private Display display;
- private Form frmFive;
- private Image imgLogo;
- private Command cmdExit;
- private Command cmdGo;
- private Command cmdOptions;
- private Command cmdReg;
- private FiveCanvas Five_Canvas;
- private Options options;
- private Reg reg;
- private static String strAbout = "";
- public FiveMIDlet()
- {
- display = Display.getDisplay(this);
- frmFive = new Form(null);
- try
- {
- imgLogo = Image.createImage("/Five.png");
- }
- catch(IOException _ex)
- {
- imgLogo = Image.createImage(1, 1);
- }
- frmFive.append(imgLogo);
- frmFive.append("GoBang Game");
- frmFive.append("仅作为学习范例n");
- cmdExit = new Command("退出", 7, 1);
- cmdGo = new Command("开局", 4, 2);
- cmdOptions = new Command("设置", 1, 3);
- cmdReg = new Command("注册", 1, 3);
- frmFive.addCommand(cmdGo);
- frmFive.addCommand(cmdOptions);
- frmFive.addCommand(cmdReg);
- frmFive.addCommand(cmdExit);
- frmFive.setCommandListener(this);
- reg = new Reg(this);
- refreshRegInfo();
- Five_Canvas = new FiveCanvas(this, reg);
- options = new Options(this);
- }
- public void startApp()
- {
- display.setCurrent(frmFive);
- }
- public void pauseApp()
- {
- }
- public void destroyApp(boolean flag1)
- {
- }
- public void commandAction(Command c, Displayable s)
- {
- if(c == cmdExit)
- {
- destroyApp(false);
- notifyDestroyed();
- } else
- if(c == cmdGo)
- {
- display.setCurrent(Five_Canvas);
- Five_Canvas.setOptions(options.borderSize(), options.computerFirst(), options.degree());
- Five_Canvas.newStage();
- } else
- if(c == cmdOptions)
- display.setCurrent(options.frmOptions());
- else
- if(c == cmdReg)
- {
- reg.register(display);
- refreshRegInfo();
- }
- }
- public void backHome()
- {
- refreshRegInfo();
- display.setCurrent(frmFive);
- }
- private void refreshRegInfo()
- {
- String sReg = "[Rigstered]n";
- frmFive.addCommand(cmdGo);
- // frmFive.removeCommand(cmdReg);
- }
- static
- {
- strAbout = "";
- }
- }