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

📄 gsm_main_frame.java

📁 用JAVA实现串口GSM发信息
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
package com;

import java.awt.BorderLayout;

import javax.swing.JPanel;
import javax.swing.JFrame;
import javax.swing.JTabbedPane;
import javax.swing.JButton;
import javax.swing.JLabel;
import java.awt.Rectangle;
import javax.swing.JComboBox;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JOptionPane;

import java.util.*;
import javax.comm.*;
import javax.swing.JList;
import javax.swing.ListSelectionModel;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.JTextField;

public class Gsm_Main_Frame extends JFrame {

	private static final long serialVersionUID = 1L;

	private JPanel jContentPane = null;

	public static JTabbedPane jTabbedPane = null;

	private JPanel r_jPanel = null;

	private JPanel s_jPanel = null;

	private JPanel makephone_jPanel = null;

	private JPanel setup_jPanel = null;

	private JButton ajButton = null;

	private JButton bjButton1 = null;

	private JPanel n_jPanel = null;

	private JLabel phone_jLabel = null;

	private JLabel msgs_jLabel1 = null;

	private JLabel ststem_jLabel1 = null;

	private JButton send_jButton = null;

	private JButton save_jButton = null;

	private JButton clear_jButton = null;

	private JScrollPane msgs_jScrollPane = null;

	private JTextArea msgs_jTextArea = null;

	private JPanel friends_jPanel = null;

	private JLabel com_jLabel = null;

	private JLabel baudrate_jLabel = null;

	private JLabel ststem_jLabel = null;

	private JComboBox com_jComboBox = null;

	private JComboBox baudrate_jComboBox = null;

	private JButton ok_jButton = null;

	public static SendMsg sendMsg = new SendMsg(); // @jve:decl-index=0:

	public static String com = null;// com口选择

	public static String bt = null;// 波特率选择

	private JLabel phoneNumber_jLabel = null;

	private JButton call_jButton = null;

	private JButton get_jButton = null;

	private JButton cancel_jButton = null;

	private JScrollPane system_send_jScrollPane = null;

	public static JTextArea system_send_jTextArea = null;// 发送界面

	private JLabel system_call_jLabel = null;

	private JScrollPane system_call_jScrollPane = null;

	public static JTextArea system_call_jTextArea = null;// 拨号界面

	private JScrollPane system_setup_jScrollPane = null;

	public static JTextArea system_setup_jTextArea = null;// 初始化界面

	public static boolean isSetup = false;
	public static boolean enableAotuAes = true;

	public static String PhoneNumber = null;

	public static String Msgs = null;

	public static String Call_PhoneNumber = null;

	public static JLabel infor_jLabel = null;

	private JLabel msgsList_jLabel = null;

	private JLabel msgsInfo_jLabel = null;

	private JButton del_jButton = null;

	private JScrollPane msgInfo_jScrollPane = null;

	private JTextArea msgInfo_jTextArea = null;

	private JButton sendsDel_jButton = null;

	private JLabel sendsMsgList_jLabel = null;

	private JLabel sendsMsgInfo_jLabel = null;

	private JScrollPane sendsMsgList_jScrollPane = null;

	private JList sends_jList = null;

	private JScrollPane sendsMsgInfo_jScrollPane = null;

	private JTextArea sendsMsgInfo_jTextArea = null;

	private JScrollPane recMsgList_jScrollPane = null;

	public static JList recMsgList_jList = null;

	public static String[] recivesMsg = { "请先初始化通信模块以便读取信息" };
	public static String[] oldMsg = recivesMsg;

	String[] sendsMsg = null;

	String[] friends = null;

	private JLabel find_name_jLabel = null;

	private JTextField find_name_jTextField = null;

	private JButton find_name_jButton = null;

	private JLabel friends_name_jLabel = null;

	private JScrollPane friends_name_jScrollPane = null;

	private JList friends_name_jList = null;

	private JButton addFriend_jButton = null;

	private JLabel me1_jLabel = null;

	private JLabel me2_jLabel = null;

	private JLabel me3_jLabel = null;

	private JLabel me4_jLabel = null;

	private JLabel me5_jLabel = null;

	private JLabel me6_jLabel = null;

	Gb2Pdu gb2pdu = new Gb2Pdu(); // @jve:decl-index=0:

	private JButton repRec_MsgList_jButton = null;

	private JLabel insterFriend_jLabel = null;

	private JLabel insterMobel_jLabel = null;

	private JLabel insterTel_jLabel = null;

	private JTextField insterFriendName_jTextField = null;

	private JTextField insterFriendMobel_jTextField = null;

	private JTextField insterFriendTel_jTextField = null;

	private JLabel sendInfo_jLabel = null;

	private SaveFile saveFile = new SaveFile();  //  @jve:decl-index=0:

	private int sendsMsg_length = 0;

	private int friends_length = 0;

	private JButton saveToSends_jButton = null;

	private JButton delFriend_jButton = null;

	private JTextField sendNumber_jTextField = null;

	private JButton sendFind_jButton = null;

	private JTextField callFind_jTextField = null;

	private JButton callFind_jButton = null;

	private JButton telEt_jButton = null;

	private JButton mobelEt_jButton = null;
	
	boolean addTo=false;//确定通信录中点击选择号码时添加的位置,false为写信息,true为通话

	private JPanel AotuRes_jPanel = null;

	private JButton AotuON_jButton = null;

	private JButton AotuOff_jButton = null;

	private JLabel aotu_jLabel = null;

	private JScrollPane aotu_jScrollPane = null;

	public static JTextArea aotu_jTextArea = null;

	private JLabel me7_jLabel1 = null;

	/**
	 * This is the default constructor
	 */
	public Gsm_Main_Frame() {
		super();
		initialize();
	}

	/**
	 * This method initializes this
	 * 
	 * @return void
	 */
	private void initialize() {
		this.setSize(600, 450);
		this.setContentPane(getJContentPane());
		this.setTitle("GSM信息平台1.0");
		this.addWindowListener(new java.awt.event.WindowAdapter() {
			public void windowClosing(java.awt.event.WindowEvent e) {
				System.out.println("windowClosing()"); // TODO Auto-generated
				// Event stub
				// windowClosing()
				System.exit(0);
			}
		});
		this.addWindowStateListener(new java.awt.event.WindowAdapter() {
			public void windowStateChanged(java.awt.event.WindowEvent e) {
				System.out.println("chenged"); // TODO Auto-generated			
			}
		});
	}

	/**
	 * This method initializes jContentPane
	 * 
	 * @return javax.swing.JPanel
	 */
	private JPanel getJContentPane() {
		if (jContentPane == null) {
			jContentPane = new JPanel();
			jContentPane.setLayout(new BorderLayout());
			jContentPane.add(getJTabbedPane(), BorderLayout.CENTER);
		}
		return jContentPane;
	}

	/**
	 * This method initializes jTabbedPane
	 * 
	 * @return javax.swing.JTabbedPane
	 */
	private JTabbedPane getJTabbedPane() {
		if (jTabbedPane == null) {
			jTabbedPane = new JTabbedPane();
			jTabbedPane.addTab("收件箱", null, getR_jPanel(), null);
			jTabbedPane.addTab("发件箱", null, getS_jPanel(), null);
			jTabbedPane.addTab("写信息", null, getN_jPanel(), null);
			jTabbedPane.addTab("拨打电话", null, getMakephone_jPanel(), null);
			jTabbedPane.addTab("模块初始化", null, getSetup_jPanel(), null);
			jTabbedPane.addTab("通信录", null, getFriends_jPanel(), null);
			jTabbedPane.addTab("监控系统服务端", null, getAotuRes_jPanel(), null);
			jTabbedPane.setSelectedComponent(getSetup_jPanel());
		}
		return jTabbedPane;
	}

	/**
	 * This method initializes r_jPanel
	 * 
	 * @return javax.swing.JPanel
	 */
	private JPanel getR_jPanel() {
		if (r_jPanel == null) {
			me1_jLabel = new JLabel();
			me1_jLabel.setBounds(new Rectangle(123, 339, 346, 29));
			me1_jLabel
					.setText("Copyright  2007 - 2009 Panjianjun. E-mail:panjj-999@163.com");
			msgsInfo_jLabel = new JLabel();
			msgsInfo_jLabel.setBounds(new Rectangle(96, 175, 55, 18));
			msgsInfo_jLabel.setText("信息内容:");
			msgsList_jLabel = new JLabel();
			msgsList_jLabel.setBounds(new Rectangle(96, 30, 55, 18));
			msgsList_jLabel.setText("信息列表:");
			r_jPanel = new JPanel();
			r_jPanel.setLayout(null);
			r_jPanel.add(getAjButton(), null);
			r_jPanel.add(msgsList_jLabel, null);
			r_jPanel.add(msgsInfo_jLabel, null);
			r_jPanel.add(getDel_jButton(), null);
			r_jPanel.add(getMsgInfo_jScrollPane(), null);
			r_jPanel.add(getRecMsgList_jScrollPane(), null);
			r_jPanel.add(me1_jLabel, null);
			r_jPanel.add(getRepRec_MsgList_jButton(), null);
			r_jPanel.add(getSaveToSends_jButton(), null);
		}
		return r_jPanel;
	}

	/**
	 * This method initializes s_jPanel
	 * 
	 * @return javax.swing.JPanel
	 */
	private JPanel getS_jPanel() {
		if (s_jPanel == null) {
			me2_jLabel = new JLabel();
			me2_jLabel.setBounds(new Rectangle(126, 351, 345, 18));
			me2_jLabel
					.setText("Copyright  2007 - 2009 Panjianjun. E-mail:panjj-999@163.com");
			sendsMsgInfo_jLabel = new JLabel();
			sendsMsgInfo_jLabel.setBounds(new Rectangle(96, 175, 55, 18));
			sendsMsgInfo_jLabel.setText("信息内容:");
			sendsMsgList_jLabel = new JLabel();
			sendsMsgList_jLabel.setBounds(new Rectangle(96, 30, 55, 18));
			sendsMsgList_jLabel.setText("信息列表:");
			s_jPanel = new JPanel();
			s_jPanel.setLayout(null);
			s_jPanel.add(getBjButton1(), null);
			s_jPanel.add(getSendsDel_jButton(), null);
			s_jPanel.add(sendsMsgList_jLabel, null);
			s_jPanel.add(sendsMsgInfo_jLabel, null);
			s_jPanel.add(getSendsMsgList_jScrollPane(), null);
			s_jPanel.add(getSendsMsgInfo_jScrollPane(), null);
			s_jPanel.add(me2_jLabel, null);
		}
		return s_jPanel;
	}

	/**
	 * This method initializes makephone_jPanel
	 * 
	 * @return javax.swing.JPanel
	 */
	private JPanel getMakephone_jPanel() {
		if (makephone_jPanel == null) {
			me4_jLabel = new JLabel();
			me4_jLabel.setBounds(new Rectangle(125, 353, 345, 18));
			me4_jLabel
					.setText("Copyright  2007 - 2009 Panjianjun. E-mail:panjj-999@163.com");
			system_call_jLabel = new JLabel();
			system_call_jLabel.setBounds(new Rectangle(141, 212, 79, 27));
			system_call_jLabel.setText("   系统信息:");
			phoneNumber_jLabel = new JLabel();
			phoneNumber_jLabel.setText(" 请输入号码:");
			phoneNumber_jLabel.setBounds(new Rectangle(139, 78, 79, 27));
			makephone_jPanel = new JPanel();
			makephone_jPanel.setLayout(null);
			makephone_jPanel.add(phoneNumber_jLabel, null);
			makephone_jPanel.add(getCall_jButton(), null);
			makephone_jPanel.add(getGet_jButton(), null);
			makephone_jPanel.add(getCancel_jButton(), null);
			makephone_jPanel.add(system_call_jLabel, null);
			makephone_jPanel.add(getSystem_call_jScrollPane(), null);
			makephone_jPanel.add(me4_jLabel, null);
			makephone_jPanel.add(getCallFind_jTextField(), null);
			makephone_jPanel.add(getCallFind_jButton(), null);
		}
		return makephone_jPanel;
	}

	/**
	 * This method initializes setup_jPanel
	 * 
	 * @return javax.swing.JPanel
	 */
	private JPanel getSetup_jPanel() {
		if (setup_jPanel == null) {
			me5_jLabel = new JLabel();
			me5_jLabel.setBounds(new Rectangle(125, 357, 345, 18));
			me5_jLabel
					.setText("Copyright  2007 - 2009 Panjianjun. E-mail:panjj-999@163.com");
			infor_jLabel = new JLabel();
			infor_jLabel.setBounds(new Rectangle(65, 8, 454, 27));
			infor_jLabel.setText(" 提示 : 确认接线已接好,选择好连接参数后点击确定,看到系统提示再给模块上电");
			ststem_jLabel = new JLabel();
			ststem_jLabel.setBounds(new Rectangle(112, 199, 60, 25));
			ststem_jLabel.setText("系统信息:");
			baudrate_jLabel = new JLabel();
			baudrate_jLabel.setBounds(new Rectangle(112, 118, 60, 25));
			baudrate_jLabel.setText("  波 特 率:");
			com_jLabel = new JLabel();
			com_jLabel.setBounds(new Rectangle(112, 45, 60, 25));
			com_jLabel.setText(" 串口选择:");
			setup_jPanel = new JPanel();
			setup_jPanel.setLayout(null);
			setup_jPanel.add(com_jLabel, null);
			setup_jPanel.add(baudrate_jLabel, null);
			setup_jPanel.add(ststem_jLabel, null);
			setup_jPanel.add(getCom_jComboBox(), null);
			setup_jPanel.add(getBaudrate_jComboBox(), null);
			setup_jPanel.add(getOk_jButton(), null);
			setup_jPanel.add(getSystem_setup_jScrollPane(), null);
			setup_jPanel.add(infor_jLabel, null);
			setup_jPanel.add(me5_jLabel, null);
		}
		return setup_jPanel;
	}

	/**
	 * This method initializes ajButton
	 * 
	 * @return javax.swing.JButton
	 */
	private JButton getAjButton() {
		if (ajButton == null) {
			ajButton = new JButton();
			ajButton.setText("回复");
			ajButton.setBounds(new Rectangle(150, 303, 60, 28));
			ajButton.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					System.out.println("towrite_actionPerformed()"); // TODO
					// Auto-generated
					// Event
					// stub
					// actionPerformed()
					// friends_jComboBox.setToolTipText("123");
					try {						
						String str = recMsgList_jList.getSelectedValue().toString();
						String p=null;
						int bb=str.indexOf("\",\"");
						int ee=str.indexOf("\",,\"");
						if(bb!=-1&&ee!=-1)
							 p=str.substring(bb+3,ee);
						if(p.charAt(0)=='8')//86139....
							p=p.substring(2);
						sendNumber_jTextField.setText(p);
						jTabbedPane.setSelectedComponent(getN_jPanel());
					} catch (NullPointerException ex) {
						JOptionPane.showMessageDialog(null, "信息为空!");
						return;					
				}				

⌨️ 快捷键说明

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