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

📄 smsconnect.java

📁 试用JAVA通过COMM口发送短信的代码.
💻 JAVA
字号:
// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) 
// Source File Name:   SMSConnect.java

package org.cross.sms.gui;

import com.borland.jbcl.layout.VerticalFlowLayout;
import java.awt.Container;
import java.awt.event.ActionEvent;
import java.io.PrintStream;
import java.util.Enumeration;
import java.util.Vector;
import javax.comm.CommPortIdentifier;
import javax.swing.*;
import org.cross.sms.msg.SmsUtil;

// Referenced classes of package org.cross.sms.gui:
//            SMSConnect_btn_cancel_actionAdapter, SMSConnect_btn_ok_actionAdapter

public class SMSConnect extends JDialog
{

    public SMSConnect(JFrame fr)
    {
        super(fr, true);
        jLabel1 = new JLabel();
        btn_ok = new JButton();
        btn_cancel = new JButton();
        panel_port = new JPanel();
        jPanel2 = new JPanel();
        verticalFlowLayout1 = new VerticalFlowLayout();
        jLabel2 = new JLabel();
        cb_list = new JComboBox();
        panel_baud = new JPanel();
        jLabel3 = new JLabel();
        cb_baud = new JComboBox();
        panel_mobileType = new JPanel();
        jLabel4 = new JLabel();
        cb_mobileType = new JComboBox();
        try
        {
            jbInit();
        }
        catch(Exception exception)
        {
            exception.printStackTrace();
        }
    }

    private void jbInit()
        throws Exception
    {
        getContentPane().setLayout(verticalFlowLayout1);
        setSize(400, 200);
        setLocation(200, 300);
        jLabel1.setText("    \u8BF7\u9009\u62E9\u8FDE\u63A5\u4E32\u53E3:      ");
        btn_cancel.setText("\u53D6\u6D88");
        btn_cancel.addActionListener(new SMSConnect_btn_cancel_actionAdapter(this));
        btn_ok.setText("\u786E\u5B9A");
        btn_ok.addActionListener(new SMSConnect_btn_ok_actionAdapter(this));
        jLabel2.setToolTipText("");
        jLabel2.setText("                                                 ");
        setDefaultCloseOperation(3);
        setResizable(true);
        cb_list.setToolTipText("");
        jLabel3.setText("\u8BF7\u9009\u62E9\u8FDE\u63A5\u6CE2\u7279\u7387\uFF1A");
        jLabel4.setText("\u8BF7\u9009\u62E9\u624B\u673A\u7C7B\u578B\uFF1A");
        panel_port.add(jLabel1);
        panel_port.add(cb_list);
        panel_baud.add(jLabel3);
        panel_baud.add(cb_baud);
        jPanel2.add(jLabel2);
        jPanel2.add(btn_ok);
        jPanel2.add(btn_cancel);
        getContentPane().add(panel_mobileType);
        getContentPane().add(panel_port, null);
        getContentPane().add(panel_baud);
        getContentPane().add(jPanel2, null);
        panel_mobileType.add(jLabel4);
        panel_mobileType.add(cb_mobileType);
        Vector vect = getComPort();
        for(int i = 0; i < vect.size(); i++)
            cb_list.addItem(vect.get(i).toString());

        cb_baud.addItem("9600");
        cb_baud.addItem("19200");
        cb_baud.addItem("38400");
        cb_baud.addItem("57600");
        cb_baud.addItem("115200");
        cb_baud.addItem("1152000");
        cb_baud.addItem("4000000");
        cb_mobileType.setEditable(false);
        cb_mobileType.addItem("\u79FB\u52A8\uFF08\u624B\u673A\uFF09");
        cb_mobileType.addItem("\u8054\u901A\uFF08\u624B\u673A\uFF09");
    }

    public void btn_ok_actionPerformed(ActionEvent e)
    {
        m_com = cb_list.getSelectedItem().toString();
        m_baud = Integer.parseInt(cb_baud.getSelectedItem().toString());
        SmsUtil.SMSC_CODE = cmsc_center[cb_mobileType.getSelectedIndex()];
        isok = true;
        hide();
    }

    public void btn_cancel_actionPerformed(ActionEvent e)
    {
        isok = false;
        hide();
    }

    public Vector getComPort()
    {
        Vector rtn = new Vector();
        Enumeration en = CommPortIdentifier.getPortIdentifiers();
        System.out.println("begin list");
        do
        {
            if(!en.hasMoreElements())
                break;
            CommPortIdentifier portId = (CommPortIdentifier)en.nextElement();
            if(portId.getPortType() == 1)
                rtn.add(portId.getName());
        } while(true);
        return rtn;
    }

    public String m_com;
    public int m_baud;
    public boolean isok;
    JLabel jLabel1;
    JButton btn_ok;
    JButton btn_cancel;
    JPanel panel_port;
    JPanel jPanel2;
    VerticalFlowLayout verticalFlowLayout1;
    JLabel jLabel2;
    JComboBox cb_list;
    JPanel panel_baud;
    JLabel jLabel3;
    JComboBox cb_baud;
    JPanel panel_mobileType;
    JLabel jLabel4;
    JComboBox cb_mobileType;
    String cmsc_center[] = {
        "+8613800100500", "+8613010101500"
    };
}

⌨️ 快捷键说明

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