?? client5.java
字號(hào):
import java.awt.*;
import java.net.*;
import java.io.*;
import java.awt.event.*;
public class Client5 extends Frame implements Runnable{
private TextField nameBox=new TextField("<撈撫>");
private TextArea msgView=new TextArea();
private TextField sendBox=new TextField();
private BufferedReader reader;
private PrintWriter writer;
private Socket socket;
public Client5(String title){
super(title);
msgView.setEditable(false);
add(nameBox,"North");
add(msgView,"Center");
add(sendBox,"South");
sendBox.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent ae){
try{
writer.println(nameBox.getText()+" : "+ sendBox.getText());
sendBox.setText("");
}catch(Exception ie){}
}
});
pack();
}
public void run(){
while(true){
try{
msgView.append(reader.readLine()+"\n");
}catch(IOException ie){}
}
}
private void connect(){
try{
msgView.append("輯滾家南苞狼 楷搬闌 矯檔欽聰促.\n");
socket=new Socket("127.0.0.1", 7777);
msgView.append("盲潑 霖厚啊 肯豐登菌嚼聰促.\n");
reader=new BufferedReader(new InputStreamReader(socket.getInputStream()));
writer=new PrintWriter(socket.getOutputStream(), true);
new Thread(this).start();
}catch(Exception e){
msgView.append("楷搬 角菩..");
}
}
public static void main(String[] args){
Client5 client=new Client5("盲潑");
client.setVisible(true);
client.connect();
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -