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

📄 rmsanalyzer.java

📁 J2me分析工具
💻 JAVA
字号:

import java.io.IOException;

import javax.microedition.lcdui.Alert;
import javax.microedition.lcdui.AlertType;
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;
import javax.microedition.rms.RecordStoreException;


public class RMSAnalyzer extends MIDlet implements CommandListener
{

    private Display display;
    private CounterCanvas counterCanvas;
    private Alert alert;
    public static final Command startCommand = new Command("开始", Command.ITEM,
            1);
    public static final Command exitCommand = new Command("退出", Command.EXIT, 2);


    protected void startApp() throws MIDletStateChangeException
    {

        display = Display.getDisplay(this);
        alert = new Alert("错误提示");
        try
        {
            String interval = this.getAppProperty("INTER");
            int t = Integer.parseInt(interval);
            counterCanvas = new CounterCanvas(t, 0, this);
        } catch (RecordStoreException e)
        {
            this.showAlertError(e.getMessage());
        }
        Form mainForm = new Form("RMS测试器");
        Image mainImage = getMainImage("java.png");
        if (mainImage != null)
        {
            mainForm.append(mainImage);
        } else
        {
            mainForm.append("欢迎使用自由软件");
        }
        mainForm.addCommand(startCommand);
        mainForm.addCommand(exitCommand);
        mainForm.setCommandListener(this);
        display.setCurrent(mainForm);

    }

    public Image getMainImage(String name)
    {
        Image image = null;
        try
        {
            image = Image.createImage("/" + name);
        } catch (IOException e)
        {
            return null;
        }
        return image;
    }

    public Display getDisplay()
    {
        return display;
    }

    protected void pauseApp()
    {
       

    }

    protected void destroyApp(boolean arg0) throws MIDletStateChangeException
    {
     

    }

    public void commandAction(Command cmd, Displayable disp)
    {
        if (cmd == startCommand)
        {
            display.setCurrent(counterCanvas);
            counterCanvas.start();
        } else if (cmd == exitCommand)
        {
            exitMIDlet();
        }
    }

    public void exitMIDlet()
    {
        try
        {
            destroyApp(false);
            notifyDestroyed();
        } catch (MIDletStateChangeException e)
        {
            showAlertError(e.getMessage());
        }
    }

    public void showAlertError(String message)
    {
        alert.setString(message);
        alert.setType(AlertType.ERROR);
        alert.setTimeout(2500);
        display.setCurrent(alert);

    }

}

⌨️ 快捷键说明

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