📄 hellomidlet.java
字号:
} //</editor-fold>//GEN-END:|45-getter|2| //<editor-fold defaultstate="collapsed" desc=" Generated Method: listAction ">//GEN-BEGIN:|42-action|0|42-preAction /** * Performs an action assigned to the selected list element in the list component. */ public void listAction() {//GEN-END:|42-action|0|42-preAction // enter pre-action user code here String __selectedString = getList().getString(getList().getSelectedIndex());//GEN-BEGIN:|42-action|1|53-preAction if (__selectedString != null) { if (__selectedString.equals("List Element 1")) {//GEN-END:|42-action|1|53-preAction // write pre-action user code here//GEN-LINE:|42-action|2|53-postAction // write post-action user code here list.append(textField.getString().substring(0), null); list.append(textField.getString().substring(1), null); }//GEN-BEGIN:|42-action|3|42-postAction }//GEN-END:|42-action|3|42-postAction // enter post-action user code here if (__selectedString != null) { if (__selectedString.equals("sound.wav")){ //switchDisplayable(null, getForm1()); try { //here write some command Player player = Manager.createPlayer("file:///E:/Aatest/sound.wav"); player.realize(); player.start(); //Player player = Manager.createPlayer(getClass().getResourceAsStream("file:///E:/Aatest/sound.wav"), "audio/x-wav"); } catch (IOException ex) { ex.printStackTrace(); } catch (MediaException ex) { ex.printStackTrace(); } /*try { Manager.playTone(61, 1000, 100); } catch (Exception ex){ }*/ } else { try { Player player = Manager.createPlayer("file:///E:/Aatest/"+textField.getString().charAt(0) +"/" + __selectedString); player.start(); } catch (IOException ex) { ex.printStackTrace(); } catch (MediaException ex) { ex.printStackTrace(); } } } }//GEN-BEGIN:|42-action|4| //</editor-fold>//GEN-END:|42-action|4| //<editor-fold defaultstate="collapsed" desc=" Generated Getter: screenCommand ">//GEN-BEGIN:|49-getter|0|49-preInit /** * Returns an initiliazed instance of screenCommand component. * @return the initialized component instance */ public Command getScreenCommand() { if (screenCommand == null) {//GEN-END:|49-getter|0|49-preInit // write pre-init user code here screenCommand = new Command("Screen", Command.SCREEN, 0);//GEN-LINE:|49-getter|1|49-postInit // write post-init user code here }//GEN-BEGIN:|49-getter|2| return screenCommand; } //</editor-fold>//GEN-END:|49-getter|2| //<editor-fold defaultstate="collapsed" desc=" Generated Getter: okCommand3 ">//GEN-BEGIN:|62-getter|0|62-preInit /** * Returns an initiliazed instance of okCommand3 component. * @return the initialized component instance */ public Command getOkCommand3() { if (okCommand3 == null) {//GEN-END:|62-getter|0|62-preInit // write pre-init user code here okCommand3 = new Command("Ok", Command.OK, 0);//GEN-LINE:|62-getter|1|62-postInit // write post-init user code here }//GEN-BEGIN:|62-getter|2| return okCommand3; } //</editor-fold>//GEN-END:|62-getter|2| //<editor-fold defaultstate="collapsed" desc=" Generated Getter: cancelCommand ">//GEN-BEGIN:|64-getter|0|64-preInit /** * Returns an initiliazed instance of cancelCommand component. * @return the initialized component instance */ public Command getCancelCommand() { if (cancelCommand == null) {//GEN-END:|64-getter|0|64-preInit // write pre-init user code here cancelCommand = new Command("Cancel", Command.CANCEL, 0);//GEN-LINE:|64-getter|1|64-postInit // write post-init user code here }//GEN-BEGIN:|64-getter|2| return cancelCommand; } //</editor-fold>//GEN-END:|64-getter|2| //<editor-fold defaultstate="collapsed" desc=" Generated Getter: textField ">//GEN-BEGIN:|39-getter|0|39-preInit /** * Returns an initiliazed instance of textField component. * @return the initialized component instance */ public TextField getTextField() { if (textField == null) {//GEN-END:|39-getter|0|39-preInit // write pre-init user code here textField = new TextField("textField", null, 32, TextField.ANY);//GEN-LINE:|39-getter|1|39-postInit // write post-init user code here }//GEN-BEGIN:|39-getter|2| return textField; } //</editor-fold>//GEN-END:|39-getter|2| //<editor-fold defaultstate="collapsed" desc=" Generated Getter: list ">//GEN-BEGIN:|42-getter|0|42-preInit /** * Returns an initiliazed instance of list component. * @return the initialized component instance */ public List getList() { if (list == null) {//GEN-END:|42-getter|0|42-preInit // write pre-init user code here list = new List("list", Choice.IMPLICIT);//GEN-BEGIN:|42-getter|1|42-postInit list.append("List Element 1", null); list.addCommand(getBackCommand()); list.setCommandListener(this); list.setFitPolicy(Choice.TEXT_WRAP_DEFAULT); list.setSelectedFlags(new boolean[] { false });//GEN-END:|42-getter|1|42-postInit // write post-init user code here list.append("Search " + SearchString, null); try { FileConnection fc = (FileConnection)Connector.open("file:///E:/Aatest/"+textField.getString().charAt(0)); Enumeration filelist = fc.list("*", true); while(filelist.hasMoreElements()) { list.append((String) filelist.nextElement(), null); //form.append(filelist.nextElement()); } fc.close(); } catch (IOException e){ System.out.println("=== Open error ==="); System.out.println(e); list.append("open error", null); }// try { /* Enumeration drives = FileSystemRegistry.listRoots(); list.append("The valid roots found are: ", null); while(drives.hasMoreElements()) { list.append((String) drives.nextElement(), null); } // } catch (IOException e) { list.append("root list error", null); // }*/ }//GEN-BEGIN:|42-getter|2| return list; } //</editor-fold>//GEN-END:|42-getter|2| /** * Returns a display instance. * @return the display instance. */ public Display getDisplay () { return Display.getDisplay(this); } /** * Exits MIDlet. */ public void exitMIDlet() { switchDisplayable (null, null); destroyApp(true); notifyDestroyed(); } /** * Called when MIDlet is started. * Checks whether the MIDlet have been already started and initialize/starts or resumes the MIDlet. */ public void startApp() { if (midletPaused) { resumeMIDlet (); } else { initialize (); startMIDlet (); } midletPaused = false; } /** * Called when MIDlet is paused. */ public void pauseApp() { midletPaused = true; } /** * Called to signal the MIDlet to terminate. * @param unconditional if true, then the MIDlet has to be unconditionally terminated and all resources has to be released. */ public void destroyApp(boolean unconditional) { } private void getRoots() { Enumeration drives = FileSystemRegistry.listRoots(); System.out.println("The valid roots found are: "); while(drives.hasMoreElements()) { String root = (String) drives.nextElement(); System.out.println("\t"+root); } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -