62,623
社区成员
发帖
与我相关
我的任务
分享
import java.awt.*;
import java.awt.event.*;
public class Chatclient extends Frame
{
static TextField tf = new TextField();
TextArea ta = new TextArea();
public static void main(String[] args)
{
Chatclient chatclient = new Chatclient();
chatclient.inframe();
tf.addActionListener(chatclient.new Tflistener());
}
public void inframe()
{
setLocation(400, 400);
setSize(400, 500);
this.add(tf, BorderLayout.SOUTH);
add(ta, BorderLayout.NORTH);
pack();
addWindowListener(new Mywinl());
setVisible(true);
}
private class Mywinl extends WindowAdapter
{
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
}
private class Tflistener implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
String s = tf.getText();
ta.setText(s);
tf.setText("");
}
}
}