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

📄 hellomidlet.java

📁 Attempt to write voice dictionary: search and play wav files (could be obtained from stardict voice
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* * To change this template, choose Tools | Templates * and open the template in the editor. */package hello;import java.io.IOException;import java.util.Enumeration;import javax.microedition.io.file.*;import javax.microedition.io.*;//import javax.microedition.io.file.FileConnection;import javax.microedition.media.MediaException;import javax.microedition.midlet.*;import javax.microedition.lcdui.*;import javax.microedition.media.Manager;import javax.microedition.media.Player;import org.netbeans.microedition.lcdui.pda.FileBrowser;/** * @author li */public class HelloMIDlet extends MIDlet implements CommandListener {    private boolean midletPaused = false;    private String SearchString;    //<editor-fold defaultstate="collapsed" desc=" Generated Fields ">//GEN-BEGIN:|fields|0|    private Command cancelCommand;    private Command exitCommand;    private Command okCommand;    private Command okCommand1;    private Command okCommand2;    private Command backCommand;    private Command screenCommand;    private Command okCommand3;    private Form form;    private TextField textField;    private List list;    //</editor-fold>//GEN-END:|fields|0|    /**     * The HelloMIDlet constructor.     */    public HelloMIDlet() {    }    //<editor-fold defaultstate="collapsed" desc=" Generated Methods ">//GEN-BEGIN:|methods|0|    //</editor-fold>//GEN-END:|methods|0|    //<editor-fold defaultstate="collapsed" desc=" Generated Method: initialize ">//GEN-BEGIN:|0-initialize|0|0-preInitialize    /**     * Initilizes the application.     * It is called only once when the MIDlet is started. The method is called before the <code>startMIDlet</code> method.     */    private void initialize() {//GEN-END:|0-initialize|0|0-preInitialize        // write pre-initialize user code here//GEN-LINE:|0-initialize|1|0-postInitialize        // write post-initialize user code here    }//GEN-BEGIN:|0-initialize|2|    //</editor-fold>//GEN-END:|0-initialize|2|    //<editor-fold defaultstate="collapsed" desc=" Generated Method: startMIDlet ">//GEN-BEGIN:|3-startMIDlet|0|3-preAction    /**     * Performs an action assigned to the Mobile Device - MIDlet Started point.     */    public void startMIDlet() {//GEN-END:|3-startMIDlet|0|3-preAction        // write pre-action user code here        switchDisplayable(null, getForm());//GEN-LINE:|3-startMIDlet|1|3-postAction        // write post-action user code here    }//GEN-BEGIN:|3-startMIDlet|2|    //</editor-fold>//GEN-END:|3-startMIDlet|2|    //<editor-fold defaultstate="collapsed" desc=" Generated Method: resumeMIDlet ">//GEN-BEGIN:|4-resumeMIDlet|0|4-preAction    /**     * Performs an action assigned to the Mobile Device - MIDlet Resumed point.     */    public void resumeMIDlet() {//GEN-END:|4-resumeMIDlet|0|4-preAction        // write pre-action user code here//GEN-LINE:|4-resumeMIDlet|1|4-postAction        // write post-action user code here    }//GEN-BEGIN:|4-resumeMIDlet|2|    //</editor-fold>//GEN-END:|4-resumeMIDlet|2|    //<editor-fold defaultstate="collapsed" desc=" Generated Method: switchDisplayable ">//GEN-BEGIN:|5-switchDisplayable|0|5-preSwitch    /**     * Switches a current displayable in a display. The <code>display</code> instance is taken from <code>getDisplay</code> method. This method is used by all actions in the design for switching displayable.     * @param alert the Alert which is temporarily set to the display; if <code>null</code>, then <code>nextDisplayable</code> is set immediately     * @param nextDisplayable the Displayable to be set     */    public void switchDisplayable(Alert alert, Displayable nextDisplayable) {//GEN-END:|5-switchDisplayable|0|5-preSwitch        // write pre-switch user code here        Display display = getDisplay();//GEN-BEGIN:|5-switchDisplayable|1|5-postSwitch        if (alert == null) {            display.setCurrent(nextDisplayable);        } else {            display.setCurrent(alert, nextDisplayable);        }//GEN-END:|5-switchDisplayable|1|5-postSwitch        // write post-switch user code here    }//GEN-BEGIN:|5-switchDisplayable|2|    //</editor-fold>//GEN-END:|5-switchDisplayable|2|    //<editor-fold defaultstate="collapsed" desc=" Generated Method: commandAction for Displayables ">//GEN-BEGIN:|7-commandAction|0|7-preCommandAction    /**     * Called by a system to indicated that a command has been invoked on a particular displayable.     * @param command the Command that was invoked     * @param displayable the Displayable where the command was invoked     */    public void commandAction(Command command, Displayable displayable) {//GEN-END:|7-commandAction|0|7-preCommandAction        // write pre-action user code here        if (displayable == form) {//GEN-BEGIN:|7-commandAction|1|19-preAction            if (command == exitCommand) {//GEN-END:|7-commandAction|1|19-preAction                // write pre-action user code here                exitMIDlet();//GEN-LINE:|7-commandAction|2|19-postAction                // write post-action user code here            } else if (command == okCommand2) {//GEN-LINE:|7-commandAction|3|41-preAction                // write pre-action user code here                SearchString = textField.getString();                                list = null; //CHECK WHO COLLECT THE GARBAGE!!!!!!!!!!!                                //list.deleteAll(); //delete list elements not list                //list.append("Search " + SearchString, null); //App error                                switchDisplayable(null, getList());//GEN-LINE:|7-commandAction|4|41-postAction                // write post-action user code here            }//GEN-BEGIN:|7-commandAction|5|43-preAction        } else if (displayable == list) {            if (command == List.SELECT_COMMAND) {//GEN-END:|7-commandAction|5|43-preAction                // write pre-action user code here                listAction();//GEN-LINE:|7-commandAction|6|43-postAction                // write post-action user code here            } else if (command == backCommand) {//GEN-LINE:|7-commandAction|7|46-preAction                // write pre-action user code here                switchDisplayable(null, getForm());//GEN-LINE:|7-commandAction|8|46-postAction                // write post-action user code here            }//GEN-BEGIN:|7-commandAction|9|7-postCommandAction        }//GEN-END:|7-commandAction|9|7-postCommandAction        // write post-action user code here    }//GEN-BEGIN:|7-commandAction|10|    //</editor-fold>//GEN-END:|7-commandAction|10|    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: exitCommand ">//GEN-BEGIN:|18-getter|0|18-preInit    /**     * Returns an initiliazed instance of exitCommand component.     * @return the initialized component instance     */    public Command getExitCommand() {        if (exitCommand == null) {//GEN-END:|18-getter|0|18-preInit            // write pre-init user code here            exitCommand = new Command("Exit", Command.EXIT, 0);//GEN-LINE:|18-getter|1|18-postInit            // write post-init user code here        }//GEN-BEGIN:|18-getter|2|        return exitCommand;    }    //</editor-fold>//GEN-END:|18-getter|2|    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: form ">//GEN-BEGIN:|14-getter|0|14-preInit    /**     * Returns an initiliazed instance of form component.     * @return the initialized component instance     */    public Form getForm() {        if (form == null) {//GEN-END:|14-getter|0|14-preInit            // write pre-init user code here            form = new Form("Welcome", new Item[] { getTextField() });//GEN-BEGIN:|14-getter|1|14-postInit            form.addCommand(getExitCommand());            form.addCommand(getOkCommand2());            form.setCommandListener(this);//GEN-END:|14-getter|1|14-postInit            // write post-init user code here        }//GEN-BEGIN:|14-getter|2|        return form;    }    //</editor-fold>//GEN-END:|14-getter|2|    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: okCommand ">//GEN-BEGIN:|25-getter|0|25-preInit    /**     * Returns an initiliazed instance of okCommand component.     * @return the initialized component instance     */    public Command getOkCommand() {        if (okCommand == null) {//GEN-END:|25-getter|0|25-preInit            // write pre-init user code here            okCommand = new Command("Ok", Command.OK, 0);//GEN-LINE:|25-getter|1|25-postInit            // write post-init user code here        }//GEN-BEGIN:|25-getter|2|        return okCommand;    }    //</editor-fold>//GEN-END:|25-getter|2|    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: okCommand1 ">//GEN-BEGIN:|36-getter|0|36-preInit    /**     * Returns an initiliazed instance of okCommand1 component.     * @return the initialized component instance     */    public Command getOkCommand1() {        if (okCommand1 == null) {//GEN-END:|36-getter|0|36-preInit            // write pre-init user code here            okCommand1 = new Command("Ok", Command.OK, 0);//GEN-LINE:|36-getter|1|36-postInit            // write post-init user code here        }//GEN-BEGIN:|36-getter|2|        return okCommand1;    }    //</editor-fold>//GEN-END:|36-getter|2|    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: okCommand2 ">//GEN-BEGIN:|40-getter|0|40-preInit    /**     * Returns an initiliazed instance of okCommand2 component.     * @return the initialized component instance     */    public Command getOkCommand2() {        if (okCommand2 == null) {//GEN-END:|40-getter|0|40-preInit            // write pre-init user code here                        okCommand2 = new Command("Ok", Command.OK, 0);//GEN-LINE:|40-getter|1|40-postInit            // write post-init user code here                    }//GEN-BEGIN:|40-getter|2|        return okCommand2;    }    //</editor-fold>//GEN-END:|40-getter|2|    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: backCommand ">//GEN-BEGIN:|45-getter|0|45-preInit    /**     * Returns an initiliazed instance of backCommand component.     * @return the initialized component instance     */    public Command getBackCommand() {        if (backCommand == null) {//GEN-END:|45-getter|0|45-preInit            // write pre-init user code here            backCommand = new Command("Back", Command.BACK, 0);//GEN-LINE:|45-getter|1|45-postInit            // write post-init user code here        }//GEN-BEGIN:|45-getter|2|        return backCommand;

⌨️ 快捷键说明

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