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

📄 btfirmidlet.java

📁 这是一个蓝牙五子棋的手机游戏,大家来看看呀
💻 JAVA
字号:


import java.io.IOException;
import javax.microedition.lcdui.*;
import javax.microedition.midlet.MIDlet;

public class BTFIRMIDlet extends MIDlet implements CommandListener
{
    private Display display;
    private Form form;
    private Image imgSplash;
    private Command CMD_EXIT;
    private Command CMD_PLAY;
    private Alert alert;
    private BTFIRCanvas myCanvas;
    private boolean isServer;
    private ChoiceGroup choiceType;

    public BTFIRMIDlet()
    {

        alert = new Alert("程序信息");
           
        alert.setTimeout(3000); 
     


        try
        {
            imgSplash = Image.createImage("/splash.png");
            alert.setImage(imgSplash);
        }
        catch (IOException _ex)
        {
            imgSplash = Image.createImage(1, 1);
        }

        form = new Form("");
        StringItem item = new StringItem("说明:", "本五子棋游戏支持蓝牙双人对战");
        form.append(item);
        choiceType = new ChoiceGroup("请选择连接类型:", 1);
        choiceType.append("服务器", null);
        choiceType.append("客户端", null);
        form.append(choiceType);
        CMD_PLAY = new Command("开始", 4, 2);
        CMD_EXIT = new Command("退出", 3, 1);
        form.addCommand(CMD_PLAY);
        form.addCommand(CMD_EXIT);
        form.setCommandListener(this);

    }
    public void startApp()
    {

        Display.getDisplay(this).setCurrent(alert, form);

    }
    public void pauseApp(){}
    public void destroyApp(boolean arg0){}
    public void commandAction(Command c, Displayable s)
    {
        if (c == CMD_EXIT)
        {
            exit();

        }
        else
        if (c == CMD_PLAY)
        {
            isServer = choiceType.getSelectedIndex() == 0 ? true : false;
            myCanvas = new BTFIRCanvas(this, isServer);
            Display.getDisplay(this).setCurrent(myCanvas);
            myCanvas.openConnection();
            myCanvas.newStage();
        }
    }
    public void exit()
    {
        destroyApp(false);
        notifyDestroyed();
    }
    Displayable getDisplayable()
    {
        return form;
    }
}

⌨️ 快捷键说明

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