⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mymidlet.java

📁 参考了网上资源后优化改进的五子棋手机游戏
💻 JAVA
字号:
package game;

import java.io.IOException;

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.Image;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;

/**
 * @author Administrator
 * 主类
 * TODO 要更改此生成的类型注释的模板,请转至
 * 窗口 - 首选项 - Java - 代码样式 - 代码模板
 */

public class MyMIDlet extends MIDlet implements CommandListener {

	private static Command exitCmd;  //这时也可以对exitCmd进行初始化
	private static Command okCmd;
	private static Image img = null;
    private static Form form1;  		//当前显示时要用到
	public static  MyMIDlet instance;
    private MyCanvas mycanvas;  //调入下一界面时要用到
	private Display dispaly;
	
	public MyMIDlet(){
		super();
	    instance = this;
	    dispaly = Display.getDisplay(this); //获取屏幕对象
	    okCmd = new Command("进入", Command.OK, 1); //声明一个按纽的对象变量
		exitCmd = new Command("离开", Command.EXIT, 1); 
	    form1=new Form("                  Royal Studio V1.0");
		form1.addCommand(exitCmd);  //添加按纽
		form1.addCommand(okCmd);
		form1.setCommandListener(this);  //侦听
		form1.append("                  WellCome To Play Game !                   ");
		try {
	        img=Image.createImage("/20.png");
	    } 
		catch (IOException e) { }
		form1.append(img);
		form1.append("                   Powered By Tenghe.Co");
		form1.append("                    " + " 版本信息2005.11.06 ");
    }


	protected void startApp() throws MIDletStateChangeException {	
		Display.getDisplay(MyMIDlet.instance).setCurrent(form1);
		//注意这里不能直接用display.setCurrent(form1);具体待研究
	}
	
	protected void pauseApp(){}
    
	 protected void destroyApp(boolean arg0) throws MIDletStateChangeException {
        // TODO Auto-generated method stub   	
    }
    
	
	public void commandAction(Command command, Displayable displayable) {
		if (command == okCmd){  //响应按纽,调用别的方法
		mycanvas = new MyCanvas();
		Display.getDisplay(MyMIDlet.instance).setCurrent(mycanvas); //进入下一界面
		//display.setCurrent(new MyCanvas(display));
		mycanvas.startup();
		}
		
		if (command == exitCmd) {
			//MyMIDlet.instance.quitApp(); 
			this.notifyDestroyed();
			}
		}
}

⌨️ 快捷键说明

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