基本信息
源码名称:java源码:网络调试助手
源码大小:0.04M
文件格式:.zip
开发语言:Java
更新时间:2018-03-22
   友情提示:(无需注册或充值,赞助后即可获取资源下载链接)

     嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300

本次赞助数额为: 2 元 
   源码介绍


package com.hsw.u11.netassist.view;

import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextArea;
import javax.swing.JTextField;

import org.apache.log4j.Logger;
import org.omg.CORBA.PRIVATE_MEMBER;

import com.hsw.u11.netassist.netty.NettyClient;
import com.hsw.u11.netassist.util.PropertyUtils;

import resource.Resource;

public class Workspace extends JFrame implements ActionListener {
	private NettyClient client = null;
	private static final Logger log = Logger.getLogger("login");
	/**
	 * 
	 */
	private static final long serialVersionUID = -5079550980286163160L;
	// 定义组件
	JPanel jp1, jp2, jp3 = null;// 面板
	JButton jb1, jb2;// 按钮
	JTextField jtf;// 文本
	JTextArea jta;//
	// 构造函数

	public Workspace() {
		// 创建面板

		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

		jp1 = new JPanel();
		jp2 = new JPanel();
		jp3 = new JPanel();

		// 创建按钮
		jb1 = new JButton("连接");
		jb2 = new JButton("发送");
		jb1.addActionListener(this);
		jb2.addActionListener(this);

		// 创建文本框
		jtf = new JTextField(10);
		jta = new JTextArea(10, 20);
		jtf.setText(PropertyUtils.read("host"));
		jtf.setToolTipText("请输入IP或者域名");

		// 设置布局管理
		this.setLayout(new GridLayout(3, 1));// 网格式布局

		// 加入各个组件
		jp1.add(jtf);

		jp2.add(jta);

		jp3.add(jb1);
		jp3.add(jb2);

		// 加入到JFrame
		this.add(jp1);
		this.add(jp2);
		this.add(jp3);

		// 设置窗体
		this.setTitle("NettyNetAssist v1.0");// 窗体标签
		this.setSize(400, 300);// 窗体大小
//		this.setIconImage(Resource.logo.getImage());
		this.setLocationRelativeTo(null);// 在屏幕中间显示(居中显示)
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);// 退出关闭JFrame
		this.setVisible(true);// 显示窗体

		// 锁定窗体
		this.setResizable(false);
	}

	public void actionPerformed(ActionEvent e) {
		if (e.getActionCommand() == "连接") {
			final String host = jtf.getText().trim();
			if (host.length() < 3) {
				JOptionPane.showMessageDialog(null, "请输入域名或者IP!", "提示消息", JOptionPane.WARNING_MESSAGE);
				return;
			}
			jb1.setEnabled(false);
			PropertyUtils.write("host", host);
			if (null != client)client.close();
			client = new NettyClient(21868, host);
			log.info("success");

		} else if (e.getActionCommand() == "发送") {
			if (null == client) {
				JOptionPane.showMessageDialog(null, "请先连接", "提示消息", JOptionPane.WARNING_MESSAGE);
				return;
			}
			client.write(jta.getText());
		}
	}
	

}