日期:2014-05-20 浏览次数:20863 次
private class FaSong implements ActionListener {
public void actionPerformed(ActionEvent e) {
String s=tFile.getText().trim();
tArea.setText(tArea.getText()+"\n"+s);
}
}
import java.awt.BorderLayout;
import java.awt.Frame;
import java.awt.TextArea;
import java.awt.TextField;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
public class ChatClient {
public static void main(String[] args) {
new JieMian().launghFrame();
}
}
class JieMian extends Frame {
TextField tFile = new TextField();
TextArea tArea = new TextArea();
public void launghFrame() {
setBounds(200, 300, 300, 400);
add(tFile, BorderLayout.SOUTH);
add(tArea, BorderLayout.CENTER);
tFile.addActionListener(new FaSong());
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
setVisible(true);
}
private class FaSong implements ActionListener {
public void actionPerformed(ActionEvent e) {
String s = tFile.getText().trim();
tArea.setText(tArea.getText() + "\n" + s);
tFile.setText("");
}
}
}
private class FaSong implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
String s = tFile.getText().trim();
tArea.setText(s);
tFile.setText("");
tArea.repaint();
}
}