Frame.java
上传用户:tie2000000
上传日期:2022-07-03
资源大小:4k
文件大小:5k
- package sendmsg;
- import java.awt.BorderLayout;
- import java.awt.Toolkit;
- import javax.swing.JPanel;
- import javax.swing.JFrame;
- import javax.swing.JLabel;
- import java.awt.Rectangle;
- import javax.swing.JTextField;
- import javax.swing.JButton;
- import java.awt.Dimension;
- import java.util.Timer;
- import javax.swing.JTextArea;
- public class Frame extends JFrame {
- dosend ds=new dosend(); // @jve:decl-index=0:
- private JFrame f=null;
- private static final long serialVersionUID = 1L;
- private JPanel jContentPane = null;
- private JLabel jLabel = null;
- private JTextField tfip = null;
- private JLabel jLabel1 = null;
- private JTextField tftemp = null;
- private JLabel jLabel2 = null;
- private JTextField tfdamp = null;
- private JButton jb = null;
- private JTextArea ta = null;
- private Dimension dimensions = Toolkit.getDefaultToolkit().getScreenSize();
- private int width = dimensions.width / 4, height = 240;
- private int left = 0, top = 0;
- /**
- * This is the default constructor
- */
- public Frame() {
- super();
- f=this;
- initialize();
- }
- /**
- * This method initializes this
- *
- * @return void
- */
- private void initialize() {
- this.setSize(302, 226);
- this.setContentPane(getJContentPane());
- int left = (dimensions.width - width)/4;
- int top = (dimensions.height - height)/4;
- this.setSize(new Dimension(width,height));
- this.setLocation(left, top);
- this.setTitle("发送url请求");
- this.addWindowListener(new java.awt.event.WindowAdapter() {
- public void windowClosing(java.awt.event.WindowEvent e) {
- System.exit(0);
- }
- });
- }
- /**
- * This method initializes jContentPane
- *
- * @return javax.swing.JPanel
- */
- private JPanel getJContentPane() {
- if (jContentPane == null) {
- jLabel2 = new JLabel();
- jLabel2.setBounds(new Rectangle(16, 73, 58, 18));
- jLabel2.setText("damp");
- jLabel1 = new JLabel();
- jLabel1.setBounds(new Rectangle(16, 40, 58, 18));
- jLabel1.setText("temp");
- jLabel = new JLabel();
- jLabel.setBounds(new Rectangle(16, 9, 58, 18));
- jLabel.setText("目标ip");
- jContentPane = new JPanel();
- jContentPane.setLayout(null);
- jContentPane.add(jLabel, null);
- jContentPane.add(getTfip(), null);
- jContentPane.add(jLabel1, null);
- jContentPane.add(getTftemp(), null);
- jContentPane.add(jLabel2, null);
- jContentPane.add(getTfdamp(), null);
- jContentPane.add(getJb(), null);
- jContentPane.add(getTa(), null);
- }
- return jContentPane;
- }
- /**
- * This method initializes tfip
- *
- * @return javax.swing.JTextField
- */
- private JTextField getTfip() {
- if (tfip == null) {
- tfip = new JTextField();
- tfip.setBounds(new Rectangle(138, 8, 101, 16));
- }
- return tfip;
- }
- /**
- * This method initializes tftemp
- *
- * @return javax.swing.JTextField
- */
- private JTextField getTftemp() {
- if (tftemp == null) {
- tftemp = new JTextField();
- tftemp.setBounds(new Rectangle(138, 41, 101, 16));
- }
- return tftemp;
- }
- /**
- * This method initializes tfdamp
- *
- * @return javax.swing.JTextField
- */
- private JTextField getTfdamp() {
- if (tfdamp == null) {
- tfdamp = new JTextField();
- tfdamp.setBounds(new Rectangle(138, 76, 101, 16));
- }
- return tfdamp;
- }
- /**
- * This method initializes jb
- *
- * @return javax.swing.JButton
- */
- private JButton getJb() {
- if (jb == null) {
- jb = new JButton();
- jb.setBounds(new Rectangle(179, 158, 93, 27));
- jb.setText("发送");
- jb.addActionListener(new java.awt.event.ActionListener() {
- public synchronized void actionPerformed(java.awt.event.ActionEvent e) {
- String gtfip=tfip.getText().trim();
- ta.setText("");
- if (gtfip.equals("")){
- }else{
- ta.setText("开始发送");
- ta.repaint();
- String msg="temp="+tftemp.getText().trim()+"&damp="+tfdamp.getText().trim();
- ds.settfip(gtfip);
- ds.setmsg(msg);
- Thread t=new Thread(ds);
- Thread diag = new Thread(new ThreadDiag(f, ds, "发送失败,正在循环尝试,请等待......",t,ta));
- t.start();
- diag.start();//启动等待提示框线程
- String info=ds.getinfo();
- if(!"".equals(info))
- ta.setText(info);
- System.out.print("0");
- }
- }
- });
- }
- return jb;
- }
- /**
- * This method initializes ta
- *
- * @return javax.swing.JTextArea
- */
- private JTextArea getTa() {
- if (ta == null) {
- ta = new JTextArea();
- ta.setEditable(false);
- ta.setLineWrap(true);
- ta.setBounds(new Rectangle(14, 99, 269, 55));
- }
- return ta;
- }
- public void setta(String msg){
- ta.setText(msg);
- }
- } // @jve:decl-index=0:visual-constraint="10,10"