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

📄 client3.java

📁 java关于.net编程的一些简单实例
💻 JAVA
字号:
import java.net.*;
import java.io.*;
import java.awt.*;
import java.awt.event.*;
public class Client3 extends Frame{
	private TextArea msgView=new TextArea();
	private TextField sendBox=new TextField();
	private DataInputStream reader;
	private DataOutputStream writer;
	private Socket socket;
	public Client3(){
		super("客户端测试");
		setVisible(true);
		msgView.setEditable(false);
		add(msgView,"Center");
		add(sendBox,"South");
		sendBox.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent e){
				try{
					writer.writeUTF(sendBox.getText());
					writer.flush();
					String finfo=reader.readUTF();
					msgView.setText(sendBox.getText()+"内容\n");
					msgView.append(finfo);
					sendBox.setText("");
				}catch(Exception e1){}
			}
		});
		pack();
	}
	public void connect(){
		try{
			msgView.append("尝试与服服器连接");
			socket=new Socket("127.0.0.1",7777);
			reader=new DataInputStream(socket.getInputStream());
			writer=new DataOutputStream(socket.getOutputStream());
			
		}catch(Exception e){}
	}

	
	public static void main(String[] args) {
		Client3 clientObj=new Client3();
		clientObj.connect();

	}

}

⌨️ 快捷键说明

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