📄 client3.java
字号:
import java.awt.*;
import java.net.*;
import java.io.*;
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;
Socket socket;
public Client3(String title){
super(title);
msgView.setEditable(false);
add(msgView,"Center");
add(sendBox,"South");
sendBox.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent ae){
try{
writer.writeUTF(sendBox.getText());
writer.flush();
String fileInfo=reader.readUTF();
msgView.setText("< " + sendBox.getText()+"狼 郴侩 >\n\n");
msgView.append(fileInfo);
sendBox.setText("");
}catch(Exception ie){}
}
});
pack();
}
private void connect(){
try{
msgView.append("辑滚家南苞狼 楷搬阑 矫档钦聪促.\n");
socket=new Socket("127.0.0.1", 7777);
msgView.append("楷搬 肯丰... 焊绊酵篮 颇老狼 捞抚阑 涝仿窍技夸.\n");
reader=new DataInputStream(socket.getInputStream());
writer=new DataOutputStream(socket.getOutputStream());
}catch(Exception e){
msgView.append("楷搬 角菩..");
}
}
public static void main(String[] args){
Client3 client=new Client3("辑滚 矫胶袍 颇老 焊扁");
client.setVisible(true);
client.connect();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -