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

📄 hellomidlet.java

📁 短信群发工具,基于J2ME实现的手机群发
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
/*
 * HelloMidlet.java
 *
 * Created on 2006年4月14日, 上午11:11
 */

package hello;

import javax.microedition.midlet.*;
import javax.microedition.io.*;
import javax.microedition.lcdui.*;
import javax.wireless.messaging.*;

import java.io.IOException;

/**
 *
 * @author dyzq
 */
public class HelloMidlet extends MIDlet implements CommandListener, Runnable  {
    
    /** Creates a new instance of HelloMidlet */
    public HelloMidlet() {
        tel = new ReadTel();
    }
    
    private TextBox textBox1;//GEN-BEGIN:MVDFields
    private Command exitCommand;
    private Command okCommand1;
    private Form form1;
    private StringItem stringItem1;
    private Command backCommand1;
    private Command exitCommand1;
    private List list1;
    private Command backCommand2;
    private Command okCommand2;
    private Command okCommand3;
    private Command backCommand3;
    private Command backCommand4;
    private List list2;
    private Command backCommand5;
    private Command okCommand4;
    private Command okCommand5;
    private Command okCommand6;
    private Command okCommand7;
    private Command okCommand8;
    private Command okCommand9;
    private Command okCommand10;
    private List list3;
    private Command itemCommand1;
    private Command okCommand11;
    private Command itemCommand2;
    private Command component1;
    private Command itemCommand3;
    private Command okCommand12;
    private List list4;
    private Command okCommand13;
    private List list5;
    private Command okCommand14;
    private Command backCommand6;
    private Command backCommand7;
    private Command exitCommand2;
    private Command okCommand15;
    private Command backCommand8;
    private Command exitCommand3;//GEN-END:MVDFields
    private ReadTel tel;
    private Displayable resumeScreen = get_list3();
//GEN-LINE:MVDMethods

    /** This method initializes UI of the application.//GEN-BEGIN:MVDInitBegin
     */
    private void initialize() {//GEN-END:MVDInitBegin
        // Insert pre-init code here
        getDisplay().setCurrent(get_list3());//GEN-LINE:MVDInitInit
        // Insert post-init code here
    }//GEN-LINE:MVDInitEnd
    
    /** Called by the system to indicate that a command has been invoked on a particular displayable.//GEN-BEGIN:MVDCABegin
     * @param command the Command that ws invoked
     * @param displayable the Displayable on which the command was invoked
     */
    public void commandAction(Command command, Displayable displayable) {//GEN-END:MVDCABegin
        // Insert global pre-action code here
        if (displayable == textBox1) {//GEN-BEGIN:MVDCABody
            if (command == exitCommand) {//GEN-END:MVDCABody
                // Insert pre-action code here
                exitMIDlet();//GEN-LINE:MVDCAAction13
                // Insert post-action code here
            } else if (command == okCommand3) {//GEN-LINE:MVDCACase13
                // Insert pre-action code here      
                getDisplay().setCurrent(get_list1());//GEN-LINE:MVDCAAction30
                // Insert post-action code here
            }//GEN-BEGIN:MVDCACase30
        } else if (displayable == form1) {
            if (command == exitCommand1) {//GEN-END:MVDCACase30
                // Insert pre-action code here
                exitMIDlet();//GEN-LINE:MVDCAAction21
                // Insert post-action code here
            } else if (command == backCommand3) {//GEN-LINE:MVDCACase21
                // Insert pre-action code here
                // Do nothing//GEN-LINE:MVDCAAction32
                // Insert post-action code here
            } else if (command == backCommand4) {//GEN-LINE:MVDCACase32
                // Insert pre-action code here
                getDisplay().setCurrent(get_list2());//GEN-LINE:MVDCAAction34
                // Insert post-action code here
            } else if (command == okCommand9) {//GEN-LINE:MVDCACase34
                // Insert pre-action code here
                // Do nothing//GEN-LINE:MVDCAAction59
                // Insert post-action code here              
                new Thread(this).start();
            }//GEN-BEGIN:MVDCACase59
        } else if (displayable == list1) {
            if (command == backCommand2) {//GEN-END:MVDCACase59
                // Insert pre-action code here    
                getDisplay().setCurrent(get_textBox1());//GEN-LINE:MVDCAAction26
                // Insert post-action code here
            } else if (command == okCommand2) {//GEN-LINE:MVDCACase26
                // Insert pre-action code here
                list1.getSelectedFlags(tel.sarry);
                list2 = null;
                getDisplay().setCurrent(get_list2());//GEN-LINE:MVDCAAction28
                // Insert post-action code here 
             
            } else if (command == okCommand5) {//GEN-LINE:MVDCACase28
                // Insert pre-action code here
                // Do nothing//GEN-LINE:MVDCAAction44
                // Insert post-action code here
                boolean b[] = new boolean[list1.size()];
                for(int i=0;i<list1.size();i++){
                    b[i] = true;
                }
                list1.setSelectedFlags(b);
            } else if (command == okCommand6) {//GEN-LINE:MVDCACase44
                // Insert pre-action code here
                // Do nothing//GEN-LINE:MVDCAAction51
                // Insert post-action code here
                boolean b[] = new boolean[list1.size()];
                for(int i=0;i<list1.size();i++){
                    b[i] = false;
                }
                list1.setSelectedFlags(b);
            }//GEN-BEGIN:MVDCACase51
        } else if (displayable == list2) {
            if (command == okCommand4) {//GEN-END:MVDCACase51
                // Insert pre-action code here
                for(int i=0;i<tel.fshm.length;i++){
                    tel.fshm[i] = false;
                }
                for(int i=0;i<list2.size();i++){
                    if(list2.isSelected(i)){
                        String xh = list2.getString(i).substring(0,tel.hmcd);
                        tel.fshm[Integer.parseInt(xh)] = true;
                    }                        
                }                  
                getDisplay().setCurrent(get_form1());//GEN-LINE:MVDCAAction40
                // Insert post-action code here
                
            } else if (command == backCommand5) {//GEN-LINE:MVDCACase40
                // Insert pre-action code here
                getDisplay().setCurrent(get_list1());//GEN-LINE:MVDCAAction38
                // Insert post-action code here
            } else if (command == okCommand7) {//GEN-LINE:MVDCACase38
                // Insert pre-action code here
                // Do nothing//GEN-LINE:MVDCAAction55
                // Insert post-action code here
                boolean b[] = new boolean[list2.size()];
                for(int i=0;i<list2.size();i++){
                    b[i] = true;
                }
                list2.setSelectedFlags(b);
            } else if (command == okCommand8) {//GEN-LINE:MVDCACase55
                // Insert pre-action code here
                // Do nothing//GEN-LINE:MVDCAAction57
                // Insert post-action code here
                boolean b[] = new boolean[list2.size()];
                for(int i=0;i<list2.size();i++){
                    b[i] = false;
                }
                list2.setSelectedFlags(b);
            } else if (command == okCommand10) {//GEN-LINE:MVDCACase57
                // Insert pre-action code here
                // Do nothing//GEN-LINE:MVDCAAction62
                // Insert post-action code here
                /*
                String xh = list2.getString(list2.getSelectedIndex()).substring(0,tel.hmcd);
                String callHaoMa = "tel:" + tel.hm[Integer.parseInt(xh)][0];
                list2.setTitle(Integer.toString(list2.getSelectedIndex()));
                try{
                    platformRequest(callHaoMa);
                }catch(ConnectionNotFoundException e){
                    System.out.println(e.toString());
                }
                 */
            }//GEN-BEGIN:MVDCACase62
        } else if (displayable == list4) {
            if (command == okCommand13) {//GEN-END:MVDCACase62
                                try {
                                    // Insert pre-action code here
                                    list4.getSelectedFlags(tel.sarry);
                                    list5 = null;
                                    getDisplay().setCurrent(get_list5());
                                } catch(Exception e){
                                    list4.setTitle(e.toString());
                                     list5.setTitle(e.toString());
                                }//GEN-LINE:MVDCAAction81
                // Insert post-action code here
            } else if (command == exitCommand3) {//GEN-LINE:MVDCACase81
                // Insert pre-action code here
                exitMIDlet();//GEN-LINE:MVDCAAction98
                // Insert post-action code here
            }//GEN-BEGIN:MVDCACase98
        } else if (displayable == list5) {
            if (command == okCommand14) {//GEN-END:MVDCACase98
                // Insert pre-action code here
                // Do nothing//GEN-LINE:MVDCAAction86
                // Insert post-action code here
                String xh = list5.getString(list5.getSelectedIndex()).substring(0,tel.hmcd);
                String callHaoMa = "tel:" + tel.hm[Integer.parseInt(xh)][0];
                try{
                    platformRequest(callHaoMa);
                    
                }catch(ConnectionNotFoundException e){
                    System.out.println(e.toString());
                    list5.setTitle("呼叫失败!");
                }
                
            } else if (command == backCommand6) {//GEN-LINE:MVDCACase86
                // Insert pre-action code here
                getDisplay().setCurrent(get_list4());//GEN-LINE:MVDCAAction88
                // Insert post-action code here
            }//GEN-BEGIN:MVDCACase88
        }//GEN-END:MVDCACase88
        // Insert global post-action code here
        if(command == okCommand15){
            switch (list3.getSelectedIndex()) {
                case 0:
                    getDisplay().setCurrent(get_list4());
                    break;
                case 1:
                    getDisplay().setCurrent(get_textBox1());
                    break;
            }
        }
}//GEN-LINE:MVDCAEnd
    
    /**
     * This method should return an instance of the display.
     */
    public Display getDisplay() {//GEN-FIRST:MVDGetDisplay
        return Display.getDisplay(this);
    }//GEN-LAST:MVDGetDisplay
    
    /**
     * This method should exit the midlet.
     */
    public void exitMIDlet() {//GEN-FIRST:MVDExitMidlet
        getDisplay().setCurrent(null);
        destroyApp(true);
        notifyDestroyed();
    }//GEN-LAST:MVDExitMidlet
    
    
    
    
    /** This method returns instance for textBox1 component and should be called instead of accessing textBox1 field directly.//GEN-BEGIN:MVDGetBegin7
     * @return Instance for textBox1 component
     */
    public TextBox get_textBox1() {
        if (textBox1 == null) {//GEN-END:MVDGetBegin7
            // Insert pre-init code here
            textBox1 = new TextBox("\u8BF7\u8F93\u5165\u77ED\u4FE1(V1.2)", "", 70, TextField.ANY);//GEN-BEGIN:MVDGetInit7
            textBox1.addCommand(get_exitCommand());
            textBox1.addCommand(get_okCommand3());
            textBox1.setCommandListener(this);//GEN-END:MVDGetInit7
            // Insert post-init code here
        }//GEN-BEGIN:MVDGetEnd7
        return textBox1;
    }//GEN-END:MVDGetEnd7
    
    /** This method returns instance for exitCommand component and should be called instead of accessing exitCommand field directly.//GEN-BEGIN:MVDGetBegin12
     * @return Instance for exitCommand component
     */
    public Command get_exitCommand() {
        if (exitCommand == null) {//GEN-END:MVDGetBegin12
            // Insert pre-init code here
            exitCommand = new Command("\u9000\u51FA", Command.EXIT, 1);//GEN-LINE:MVDGetInit12
            // Insert post-init code here
        }//GEN-BEGIN:MVDGetEnd12
        return exitCommand;
    }//GEN-END:MVDGetEnd12
    

⌨️ 快捷键说明

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