JTextArea?textArea?=?new?JTextArea();
OutputStream?os?=?s.getOutputStream();
PrintWriter?pw?=?new?PrintWriter(os);
BufferedWriter?bw?=?new?BufferedWriter(pw);
//寫在這里成功
JButton?button?=?new?JButton("發(fā)送");
button.addActionListener(new?ActionListener()?{
public?void?actionPerformed(ActionEvent?e)?{
try?{
????????//寫在這里失敗
bw.write("asdfasdf");
bw.flush();
}?catch?(IOException?e1)?{
e1.printStackTrace();
}
}
});學(xué)習(xí)了socket以后我想寫個窗體的程序聊天,客戶端我添加了一個按鈕,可是如果我把寫操作放在actionperformed里,服務(wù)器一點反應(yīng)都沒有,但是寫出來就可以為什么呢?
添加回答
舉報
0/150
提交
取消