📄 msgpdemo.java
字号:
package smgpapidemo;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import com.ut.smgp.api.structure.*;
import com.ut.smgp.api.*;
import java.net.*;
public class msgpDemo extends JFrame {
receiverThread receive;
int sendOkNum=0;
int sendFailNum=0;
SMGP smgp=new SMGP();
JPanel contentPane;
GridBagLayout gridBagLayout1 = new GridBagLayout();
JButton initButton = new JButton();
JButton sendButton = new JButton();
JButton closeButton = new JButton();
JTextField srcTermId = new JTextField();
JTextField destTermId = new JTextField();
JLabel jLabel1 = new JLabel();
JLabel jLabel2 = new JLabel();
JTextField priority = new JTextField();
JTextField msgFormat = new JTextField();
JTextField feeCode = new JTextField();
JLabel jLabel3 = new JLabel();
JLabel jLabel4 = new JLabel();
JLabel jLabel5 = new JLabel();
JLabel jLabel6 = new JLabel();
JTextField feeType = new JTextField();
JLabel jLabel7 = new JLabel();
JTextField msgType = new JTextField();
JCheckBox needReport = new JCheckBox();
JLabel jLabel9 = new JLabel();
JTextField successNum = new JTextField();
JLabel jLabel10 = new JLabel();
JTextField failNum = new JTextField();
JTextArea jTextArea1 = new JTextArea();
JLabel jLabel11 = new JLabel();
JTextField msgContent = new JTextField();
JTextField receiveNum = new JTextField();
JLabel jLabel12 = new JLabel();
JLabel jLabel13 = new JLabel();
JTextField receiveContent = new JTextField();
JButton jButton1 = new JButton();
JButton activeTest = new JButton();
JTextField activeTestResult = new JTextField();
JButton receiveButton = new JButton();
JTextField sendResult = new JTextField();
JLabel jLabel8 = new JLabel();
//Construct the frame
public msgpDemo() {
enableEvents(AWTEvent.WINDOW_EVENT_MASK);
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
//Component initialization
private void jbInit() throws Exception {
contentPane = (JPanel) this.getContentPane();
contentPane.setLayout(gridBagLayout1);
this.setSize(new Dimension(400, 300));
this.setTitle("短信网关SMGP API测试程序");
contentPane.setBackground(SystemColor.menu);
contentPane.setForeground(Color.black);
contentPane.setOpaque(true);
contentPane.setPreferredSize(new Dimension(750, 300));
initButton.setText("初始化");
initButton.addActionListener(new msgpDemo_initButton_actionAdapter(this));
sendButton.setEnabled(false);
sendButton.setText("发送");
sendButton.addActionListener(new msgpDemo_sendButton_actionAdapter(this));
closeButton.setEnabled(false);
closeButton.setText("关闭");
closeButton.addActionListener(new msgpDemo_closeButton_actionAdapter(this));
jLabel1.setText("目的地址");
jLabel2.setText("源地址");
srcTermId.setText("11830000000");
srcTermId.setColumns(15);
destTermId.setText("13100000000");
destTermId.setColumns(15);
priority.setText("");
priority.setColumns(15);
msgFormat.setText("15");
msgFormat.setColumns(15);
feeCode.setText("");
feeCode.setColumns(15);
jLabel3.setText("优先级");
jLabel4.setText("编码方式");
jLabel5.setText("消息类型");
jLabel6.setText("Fee Code");
feeType.setColumns(15);
jLabel7.setText("Fee Type");
msgType.setText("1");
msgType.setColumns(15);
needReport.setText("需要状态报告");
jLabel9.setText("成功数");
successNum.setEditable(false);
successNum.setText("");
successNum.setColumns(5);
successNum.addActionListener(new msgpDemo_successNum_actionAdapter(this));
jLabel10.setText("失败数");
failNum.setEditable(false);
failNum.setText("");
failNum.setColumns(5);
jTextArea1.setEditable(true);
jTextArea1.setMargin(new Insets(0, 0, 0, 0));
jTextArea1.setText("jTextArea1");
jTextArea1.setColumns(15);
jTextArea1.setLineWrap(true);
jTextArea1.setRows(5);
//p.add(jTextArea1);//then OK!
jLabel11.setText("内容");
msgContent.setText("");
jLabel12.setText("接收数量");
jLabel13.setText("msg");
receiveContent.setEditable(false);
receiveNum.setEditable(false);
receiveNum.setText("0");
receiveNum.addActionListener(new msgpDemo_receiveNum_actionAdapter(this));
jButton1.setAction(null);
jButton1.setActionCommand("");
jButton1.setText("计数清零");
jButton1.addActionListener(new msgpDemo_jButton1_actionAdapter(this));
activeTest.setText("ActiveTest");
activeTest.addActionListener(new msgpDemo_activeTest_actionAdapter(this));
activeTestResult.setEditable(false);
activeTestResult.setText("");
receiveButton.setEnabled(false);
receiveButton.setToolTipText("");
receiveButton.setText("开始接收");
receiveButton.addActionListener(new msgpDemo_receiveButton_actionAdapter(this));
jLabel8.setRequestFocusEnabled(true);
jLabel8.setText("发送状态码");
contentPane.add(jLabel1, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0
,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
contentPane.add(jLabel2, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0
,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
contentPane.add(jLabel3, new GridBagConstraints(0, 4, 1, 2, 0.0, 0.0
,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
contentPane.add(jLabel4, new GridBagConstraints(0, 6, 1, 1, 0.0, 0.0
,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
contentPane.add(jLabel5, new GridBagConstraints(0, 7, 1, 1, 0.0, 0.0
,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
contentPane.add(jLabel6, new GridBagConstraints(0, 8, 1, 1, 0.0, 0.0
,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
contentPane.add(jLabel7, new GridBagConstraints(0, 9, 1, 2, 0.0, 0.0
,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
contentPane.add(jLabel9, new GridBagConstraints(3, 3, 1, 1, 0.0, 0.0
,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
contentPane.add(jLabel10, new GridBagConstraints(3, 4, 1, 2, 0.0, 0.0
,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
contentPane.add(successNum, new GridBagConstraints(4, 3, 4, 1, 0.0, 0.0
,GridBagConstraints.SOUTHWEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 3), 69, 1));
contentPane.add(failNum, new GridBagConstraints(4, 4, 4, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 72, -2));
contentPane.add(jTextArea1, new GridBagConstraints(4, 11, 1, 1, 0.0, 0.0
,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), -423, 30));
contentPane.add(jLabel11, new GridBagConstraints(3, 6, 1, 1, 0.0, 0.0
,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
contentPane.add(msgContent, new GridBagConstraints(4, 6, 4, 1, 0.0, 0.0
,GridBagConstraints.SOUTHWEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 134, 0));
contentPane.add(needReport, new GridBagConstraints(4, 8, 4, 2, 0.0, 0.0
,GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
contentPane.add(receiveContent, new GridBagConstraints(5, 11, 3, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 133, 0));
contentPane.add(jLabel13, new GridBagConstraints(3, 11, 1, 2, 0.0, 0.0
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
contentPane.add(msgType, new GridBagConstraints(1, 7, 2, 1, 0.0, 0.0
,GridBagConstraints.SOUTH, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 112, 0));
contentPane.add(feeCode, new GridBagConstraints(1, 8, 2, 1, 0.0, 0.0
,GridBagConstraints.SOUTH, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 113, 0));
contentPane.add(feeType, new GridBagConstraints(1, 9, 2, 2, 0.0, 0.0
,GridBagConstraints.SOUTH, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 114, 0));
contentPane.add(priority, new GridBagConstraints(1, 4, 2, 2, 0.0, 0.0
,GridBagConstraints.SOUTH, GridBagConstraints.NONE, new Insets(0, 0, 5, 0), 112, 0));
contentPane.add(jLabel12, new GridBagConstraints(0, 11, 1, 2, 0.0, 0.0
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
contentPane.add(receiveNum, new GridBagConstraints(1, 11, 2, 2, 0.0, 0.0
,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 97, 0));
contentPane.add(closeButton, new GridBagConstraints(1, 0, 2, 1, 0.0, 0.0
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(11, 0, 4, 15), 0, 0));
contentPane.add(msgFormat, new GridBagConstraints(1, 6, 2, 1, 0.0, 0.0
,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 112, 0));
contentPane.add(sendButton, new GridBagConstraints(5, 2, 3, 1, 0.0, 0.0
,GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(1, 0, 7, 0), 0, 0));
contentPane.add(initButton, new GridBagConstraints(0, 0, 1, 2, 0.0, 0.0
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(11, 2, 4, 0), 0, 0));
contentPane.add(jButton1, new GridBagConstraints(2, 13, 1, 1, 0.0, 0.0
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
contentPane.add(receiveButton, new GridBagConstraints(0, 13, 2, 1, 0.0, 0.0
,GridBagConstraints.SOUTHEAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), -4, 0));
contentPane.add(srcTermId, new GridBagConstraints(2, 2, 1, 1, 0.0, 0.0
,GridBagConstraints.SOUTHWEST, GridBagConstraints.NONE, new Insets(0, 9, 0, 10), 111, 0));
contentPane.add(destTermId, new GridBagConstraints(2, 3, 1, 1, 0.0, 0.0
,GridBagConstraints.SOUTH, GridBagConstraints.NONE, new Insets(0, 11, 0, 17), 111, -1));
contentPane.add(activeTest, new GridBagConstraints(5, 13, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, -22, 0, 0), 0, 0));
contentPane.add(activeTestResult, new GridBagConstraints(6, 13, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 24), 55, 0));
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -