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

📄 gsm_main_frame.java

📁 用JAVA实现串口GSM发信息
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
				}
			});
		}
		return ajButton;
	}

	/**
	 * This method initializes bjButton1
	 * 
	 * @return javax.swing.JButton
	 */
	private JButton getBjButton1() {
		if (bjButton1 == null) {
			bjButton1 = new JButton();
			bjButton1.setText("发送");
			bjButton1.setBounds(new Rectangle(185, 308, 60, 28));
			bjButton1.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					System.out.println("send_actionPerformed()"); // TODO
					// Auto-generated
					// Event
					// stub
					// actionPerformed()
					if (!isSetup) {
						JOptionPane.showMessageDialog(null, "模块尚未初始化!");
						return;
					}
					try {
						String str=sends_jList.getSelectedValue().toString();
						PhoneNumber = str.substring(0,str.indexOf("\""));
						Msgs = str.substring(str.indexOf("\"")+1);
						Thread tj1 = new Sending(); // 创建线程1,启动后发送信息
						tj1.setDaemon(true);
						tj1.start();
						jTabbedPane.setSelectedComponent(getN_jPanel());
					} catch (NullPointerException ex) {
						JOptionPane.showMessageDialog(null, "号码为空!");
						return;
					}
					
				}
			});
		}
		return bjButton1;
	}

	/**
	 * This method initializes n_jPanel
	 * 
	 * @return javax.swing.JPanel
	 */
	private JPanel getN_jPanel() {
		if (n_jPanel == null) {
			sendInfo_jLabel = new JLabel();
			sendInfo_jLabel.setBounds(new Rectangle(226, 53, 164, 18));
			sendInfo_jLabel.setText("群发信息时号码间用\" , \"隔开");
			me3_jLabel = new JLabel();
			me3_jLabel.setBounds(new Rectangle(143, 356, 345, 18));
			me3_jLabel
					.setText("Copyright  2007 - 2009 Panjianjun. E-mail:panjj-999@163.com");
			ststem_jLabel1 = new JLabel();
			ststem_jLabel1.setBounds(new Rectangle(57, 238, 67, 25));
			ststem_jLabel1.setText("  系统信息:");
			msgs_jLabel1 = new JLabel();
			msgs_jLabel1.setBounds(new Rectangle(57, 80, 67, 25));
			msgs_jLabel1.setText("  信息内容:");
			phone_jLabel = new JLabel();
			phone_jLabel.setText("  对方号码:");
			phone_jLabel.setBounds(new Rectangle(57, 25, 67, 25));
			n_jPanel = new JPanel();
			n_jPanel.setLayout(null);
			n_jPanel.add(phone_jLabel, null);
			n_jPanel.add(msgs_jLabel1, null);
			n_jPanel.add(ststem_jLabel1, null);
			n_jPanel.add(getSend_jButton(), null);
			n_jPanel.add(getSave_jButton(), null);
			n_jPanel.add(getClear_jButton(), null);
			n_jPanel.add(getMsgs_jScrollPane(), null);
			n_jPanel.add(getSystem_send_jScrollPane(), null);
			n_jPanel.add(me3_jLabel, null);
			n_jPanel.add(sendInfo_jLabel, null);
			n_jPanel.add(getSendNumber_jTextField(), null);
			n_jPanel.add(getSendFind_jButton(), null);
		}
		return n_jPanel;
	}

	/**
	 * This method initializes send_jButton
	 * 
	 * @return javax.swing.JButton
	 */
	private JButton getSend_jButton() {
		if (send_jButton == null) {
			send_jButton = new JButton();
			send_jButton.setBounds(new Rectangle(185, 196, 65, 22));
			send_jButton.setText("发送");
			send_jButton.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					System.out.println("sendMsg_actionPerformed()"); // TODO
					// Auto-generated
					// Event
					// stub
					// actionPerformed()
					if (!isSetup) {
						JOptionPane.showMessageDialog(null, "模块尚未初始化!");
						return;
					}
					try {
						PhoneNumber = sendNumber_jTextField.getText();
						if(PhoneNumber==null||PhoneNumber.equals("")){
							JOptionPane.showMessageDialog(null, "号码为空!");
							return;
						}
							
						Msgs = msgs_jTextArea.getText();
						Thread tj1 = new Sending(); // 创建线程1,启动后发送信息
						tj1.setDaemon(true);
						tj1.start();
					} catch (NullPointerException ex) {
						JOptionPane.showMessageDialog(null, "号码为空!");
						return;
					}
				}
			});
		}
		return send_jButton;
	}

	/**
	 * This method initializes save_jButton
	 * 
	 * @return javax.swing.JButton
	 */
	private JButton getSave_jButton() {
		if (save_jButton == null) {
			save_jButton = new JButton();
			save_jButton.setBounds(new Rectangle(285, 196, 65, 22));
			save_jButton.setText("保存");
			save_jButton.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					System.out.println("actionPerformed()"); // TODO
					// Auto-generated
					// Event stub
					// actionPerformed()
					try {
						String p = sendNumber_jTextField.getText();// 提取号码
						if(p==null||p.equals("")){
							JOptionPane.showMessageDialog(null, "号码为空!");
							return;
						}
							
						String m = Msgs = msgs_jTextArea.getText();// 提取信息内容
						sendsMsg[sendsMsg_length++] = p + "\"" + m;// 添加到信息列表
						System.out.println("now_sid="+sendsMsg_length);
						if (saveFile.saveMsg(sendsMsg))// 保存文件
							JOptionPane.showMessageDialog(null, "信息已保存至收件箱!");						
						sends_jList.setListData(sendsMsg);
						sends_jList.revalidate();
						sends_jList.repaint();// 刷新信息列表
					} catch (NullPointerException ex) {
						JOptionPane.showMessageDialog(null, "号码为空!");
						return;
					}
				}
			});
		}
		return save_jButton;
	}

	/**
	 * This method initializes clear_jButton
	 * 
	 * @return javax.swing.JButton
	 */
	private JButton getClear_jButton() {
		if (clear_jButton == null) {
			clear_jButton = new JButton();
			clear_jButton.setBounds(new Rectangle(385, 196, 65, 22));
			clear_jButton.setText("清空");
			clear_jButton
					.addActionListener(new java.awt.event.ActionListener() {
						public void actionPerformed(java.awt.event.ActionEvent e) {
							System.out.println("actionPerformed()"); // TODO
							// Auto-generated
							// Event
							// stub
							// actionPerformed()
							msgs_jTextArea.setText("");
						}
					});
		}
		return clear_jButton;
	}

	/**
	 * This method initializes msgs_jScrollPane
	 * 
	 * @return javax.swing.JScrollPane
	 */
	private JScrollPane getMsgs_jScrollPane() {
		if (msgs_jScrollPane == null) {
			msgs_jScrollPane = new JScrollPane();
			msgs_jScrollPane.setBounds(new Rectangle(149, 80, 341, 95));
			msgs_jScrollPane.setViewportView(getMsgs_jTextArea());
		}
		return msgs_jScrollPane;
	}

	/**
	 * This method initializes msgs_jTextArea
	 * 
	 * @return javax.swing.JTextArea
	 */
	private JTextArea getMsgs_jTextArea() {
		if (msgs_jTextArea == null) {
			msgs_jTextArea = new JTextArea();
			msgs_jTextArea.setLineWrap(true);
			msgs_jTextArea.setWrapStyleWord(true);
		}
		return msgs_jTextArea;
	}

	/**
	 * This method initializes friends_jPanel
	 * 
	 * @return javax.swing.JPanel
	 */
	private JPanel getFriends_jPanel() {
		if (friends_jPanel == null) {
			insterTel_jLabel = new JLabel();
			insterTel_jLabel.setBounds(new Rectangle(273, 248, 29, 18));
			insterTel_jLabel.setText("固话:");
			insterMobel_jLabel = new JLabel();
			insterMobel_jLabel.setBounds(new Rectangle(142, 281, 29, 18));
			insterMobel_jLabel.setText("手机:");
			insterFriend_jLabel = new JLabel();
			insterFriend_jLabel.setBounds(new Rectangle(119, 248, 29, 18));
			insterFriend_jLabel.setText("姓名:");
			me6_jLabel = new JLabel();
			me6_jLabel.setBounds(new Rectangle(117, 356, 345, 18));
			me6_jLabel
					.setText("Copyright  2007 - 2009 Panjianjun. E-mail:panjj-999@163.com");
			friends_name_jLabel = new JLabel();
			friends_name_jLabel.setBounds(new Rectangle(97, 90, 55, 18));
			friends_name_jLabel.setText("通信列表:");
			find_name_jLabel = new JLabel();
			find_name_jLabel.setBounds(new Rectangle(97, 54, 55, 18));
			find_name_jLabel.setText("输入内容:");
			friends_jPanel = new JPanel();
			friends_jPanel.setLayout(null);
			friends_jPanel.add(find_name_jLabel, null);
			friends_jPanel.add(getFind_name_jTextField(), null);
			friends_jPanel.add(getFind_name_jButton(), null);
			friends_jPanel.add(friends_name_jLabel, null);
			friends_jPanel.add(getFriends_name_jScrollPane(), null);
			friends_jPanel.add(getAddFriend_jButton(), null);
			friends_jPanel.add(me6_jLabel, null);
			friends_jPanel.add(insterFriend_jLabel, null);
			friends_jPanel.add(insterMobel_jLabel, null);
			friends_jPanel.add(insterTel_jLabel, null);
			friends_jPanel.add(getInsterFriendName_jTextField(), null);
			friends_jPanel.add(getInsterFriendMobel_jTextField(), null);
			friends_jPanel.add(getInsterFriendTel_jTextField(), null);
			friends_jPanel.add(getDelFriend_jButton(), null);
			friends_jPanel.add(getTelEt_jButton(), null);
			friends_jPanel.add(getMobelEt_jButton(), null);
		}
		return friends_jPanel;
	}

	/**
	 * This method initializes com_jComboBox
	 * 
	 * @return javax.swing.JComboBox
	 */
	private JComboBox getCom_jComboBox() {
		if (com_jComboBox == null) {
			com_jComboBox = new JComboBox();
			com_jComboBox.setBounds(new Rectangle(184, 48, 292, 21));
			CommPortIdentifier portId = null;
			// 列出可用串口
			Enumeration en = CommPortIdentifier.getPortIdentifiers();
			while (en.hasMoreElements()) {
				portId = (CommPortIdentifier) en.nextElement();
				// 如果端口类型是串口,则打印出其端口信息
				if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL) {
					com_jComboBox.addItem(portId.getName());
				}
			}
			com_jComboBox.setEditable(false);
		}
		return com_jComboBox;
	}

	/**
	 * This method initializes baudrate_jComboBox
	 * 
	 * @return javax.swing.JComboBox
	 */
	private JComboBox getBaudrate_jComboBox() {
		if (baudrate_jComboBox == null) {
			baudrate_jComboBox = new JComboBox();
			baudrate_jComboBox.setBounds(new Rectangle(184, 118, 292, 21));
			// 110、300、600、1200、4800、9600和19200
			baudrate_jComboBox.addItem("110");
			baudrate_jComboBox.addItem("300");
			baudrate_jComboBox.addItem("600");
			baudrate_jComboBox.addItem("1200");
			baudrate_jComboBox.addItem("4800");
			baudrate_jComboBox.addItem("9600");
			baudrate_jComboBox.addItem("19200");
			baudrate_jComboBox.addItem("38400");
			baudrate_jComboBox.addItem("57600");
			baudrate_jComboBox.addItem("115200");
			baudrate_jComboBox.addItem("230400");
			baudrate_jComboBox.addItem("460800");
			baudrate_jComboBox.addItem("920600");
			baudrate_jComboBox.setEditable(true);
		}
		return baudrate_jComboBox;
	}

	/**
	 * This method initializes ok_jButton
	 * 
	 * @return javax.swing.JButton
	 */
	private JButton getOk_jButton() {
		if (ok_jButton == null) {
			ok_jButton = new JButton();
			ok_jButton.setBounds(new Rectangle(243, 158, 76, 29));
			ok_jButton.setText("确 定");
			ok_jButton.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					System.out.println("SetGprs_actionPerformed()"); // TODO
					// Auto-generated
					// Event
					// stub
					// actionPerformed()
					if (isSetup) {// 重启
						int aa = 1;
						aa = JOptionPane.showConfirmDialog(null,
								"确定要重新初始化通信模块吗?", "警告",
								JOptionPane.OK_CANCEL_OPTION);
						System.out.println("aa=" + aa);
						if (aa == JOptionPane.YES_OPTION) {// 没有取消,继续初始化
							sendMsg.close_Gprs();// 关闭模块,以便重启
						} else {// 取消重启
							return;
						}
					}
					try {// 正常
						com = com_jComboBox.getSelectedItem().toString();
						bt = baudrate_jComboBox.getSelectedItem().toString();
						// if(com!=null||bt!=null){
						Thread tj1 = new SetGprs(); // 创建线程1,启动后初始化模块
						tj1.setDaemon(true);
						tj1.start();
					} catch (NullPointerException ex) {
						JOptionPane.showMessageDialog(null, "Com口或波特率未选择!");
						return;
					}
				}

			});
		}
		return ok_jButton;
	}

	/**
	 * This method initializes call_jButton
	 * 
	 * @return javax.swing.JButton
	 */
	private JButton getCall_jButton() {
		if (call_jButton == null) {
			call_jButton = new JButton();
			call_jButton.setBounds(new Rectangle(150, 163, 70, 27));
			call_jButton.setText("拨号");
			call_jButton.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					System.out.println("makeCall_actionPerformed()"); // TODO
					// Auto-generated
					// Event
					// stub
					// actionPerformed()
					if (!isSetup) {
						JOptionPane.showMessageDialog(null, "模块尚未初始化!");
						return;
					}
					try {
						Call_PhoneNumber = callFind_jTextField.getText();
						
						if (Call_PhoneNumber .equals("") || Call_PhoneNumber == null)
							JOptionPane.showMessageDialog(null, "号码为空!");
						else {
							Thread tj1 = new Calling(); // 创建线程1,启动后拨打电话
							tj1.setDaemon(true);
							tj1.start();
						}						
					} catch (NullPointerException ex) {
						JOptionPane.showMessageDialog(null, "号码为空!");
						return;
					}
				}

			});
		}
		return call_jButton;
	}

	/**
	 * This method initializes get_jButton
	 * 
	 * @return javax.swing.JButton
	 */
	private JButton getGet_jButton() {
		if (get_jButton == null) {
			get_jButton = new JButton();
			get_jButton.setBounds(new Rectangle(260, 163, 70, 27));
			get_jButton.setText("接听");
			get_jButton.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					System.out.println("actionPerformed()"); // TODO
					// Auto-generated
					// Event stub
					// actionPerformed()
					if (!isSetup) {
						JOptionPane.showMessageDialog(null, "模块尚未初始化!");
						return;
					}
					sendMsg.getCall();
				}
			});
		}
		return get_jButton;
	}

	/**
	 * This method initializes cancel_jButton
	 * 
	 * @return javax.swing.JButton
	 */
	private JButton getCancel_jButton() {
		if (cancel_jButton == null) {
			cancel_jButton = new JButton();
			cancel_jButton.setBounds(new Rectangle(375, 163, 70, 27));
			cancel_jButton.setText("挂断");
			cancel_jButton
					.addActionListener(new java.awt.event.ActionListener() {
						public void actionPerformed(java.awt.event.ActionEvent e) {
							System.out.println("actionPerformed()"); // TODO
							// Auto-generated
							// Event
							// stub
							// actionPerformed()
							if (!isSetup) {
								JOptionPane.showMessageDialog(null, "模块尚未初始化!");
								return;
							}
							sendMsg.cancelCall();

⌨️ 快捷键说明

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