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

📄 mainmidlet.java~2~

📁 一個手機程序(電子詞典),一個不可多得的源碼程序,是學習J2ME的好東東.
💻 JAVA~2~
字号:
// Decompiled by Jad v1.5.7g. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi
// Source File Name:   MainMIDlet.java

package test;

import javax.microedition.lcdui.*;
import javax.microedition.midlet.MIDlet;

// Referenced classes of package ecdict:
//            DictFile, DictWord

public class MainMIDlet extends MIDlet
    implements CommandListener
{

    public static MainMIDlet instance;
    private Display display;
    private DictFile dictFile;
    private Form mainForm;
    private TextBox edtWord;
    private Command cmdExit;
    private Command cmdAbout;
    private Command cmdHelp;
    private Command cmdInput;
    private Command cmdNext;
    private Command cmdOk;
    private Command cmdCancel;
    private static String AboutStr = "〖英汉字典〗\n【作者】徐志强\n【发布】2003-12-11\n【大小】110k\n【说明】这是一个免费程序,如有问题请 Email 至 xuzhq@163.com ,谢谢使用。";
    private static String HelpStr = "启动程序后选中『输入』,输入要检索的英语单词后按『确定』开始查询,查询过程视手机情况大约需要3-15秒;注意:在查询期间请不要重复按确定,检索到单词后可以按『下一个』检索下一个匹配单词。";

    public MainMIDlet()
    {
        dictFile = new DictFile();
        mainForm = new Form("英汉字典");
        edtWord = new TextBox("请输入单词", "", 20, 0);
        cmdExit = new Command("退出", 7, 1);
        cmdAbout = new Command("关于", 1, 1);
        cmdHelp = new Command("帮助", 1, 1);
        cmdInput = new Command("输入", 1, 1);
        cmdNext = new Command("下一个", 1, 1);
        cmdOk = new Command("确定", 4, 0);
        cmdCancel = new Command("取消", 3, 1);
        instance = this;
    }

    public void startApp()
    {
        display = Display.getDisplay(this);
        mainForm.addCommand(cmdInput);
        mainForm.addCommand(cmdNext);
        mainForm.addCommand(cmdAbout);
        mainForm.addCommand(cmdHelp);
        mainForm.addCommand(cmdExit);
        mainForm.append(new StringItem("请输入", ""));
        mainForm.setCommandListener(this);
        edtWord.addCommand(cmdOk);
        edtWord.addCommand(cmdCancel);
        edtWord.setCommandListener(this);
        display.setCurrent(mainForm);
    }

    public void pauseApp()
    {
    }

    public void destroyApp(boolean flag)
    {
    }

    public static void quitApp()
    {
        instance.destroyApp(true);
        instance.notifyDestroyed();
        instance = null;
    }

    public void commandAction(Command c, Displayable s)
    {
        if(s == edtWord)
        {
            if(c.getCommandType() == 4)
            {
                display.setCurrent(mainForm);
                try
                {
                    DictWord Word = dictFile.SearchWord(edtWord.getString().toLowerCase());
                    String AStr = Word.GetWord() + "\n" + Word.GetWordDesc();
                    mainForm.get(0).setLabel(AStr);
                }
                catch(Exception ex) { }
            } else
            if(c.getCommandType() == 3)
                display.setCurrent(mainForm);
        } else
        if(c == cmdExit)
            quitApp();
        else
        if(c == cmdAbout)
        {
            Alert alert = new Alert("关于", AboutStr, null, AlertType.WARNING);
            display.setCurrent(alert);
        } else
        if(c == cmdHelp)
        {
            Alert alert = new Alert("帮助", HelpStr, null, AlertType.WARNING);
            display.setCurrent(alert);
        } else
        if(c == cmdInput)
        {
            edtWord.setString("");
            display.setCurrent(edtWord);
        } else
        if(c == cmdNext)
            try
            {
                DictWord Word = dictFile.FindNext();
                String AStr = Word.GetWord() + "\n" + Word.GetWordDesc();
                mainForm.get(0).setLabel(AStr);
            }
            catch(Exception ex) { }
    }

}

⌨️ 快捷键说明

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