import java.awt.*;
import java.awt.event.*;
public class TextFA
{
private Frame f = new Frame("TextArea和TextFiled示例");
private TextField tf = new TextField(20);
private TextArea ta = new TextArea("",5,10,TextArea.SCROLLBARS_BOTH);
public static void main(String[] args)
{
TextFA that = new TextFA();
that.go();
}
void go()
{
f.setLayout(new BorderLayout(0,10));
f.add("North",tf);
f.add("Center",ta);
tf.addActionListener(new TextHandle());
f.addWindowListener(new WindowHandle());
f.setSize(300,400);
f.setResizable(true);
f.setVisible(true);
}
class TextHandle implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
ta.append(tf.getText()+"/n");
tf.setText("");
}
}
class WindowHandle extends WindowAdapter
{
public void windowClosing(WindowEvent e)
{
System.exit(1);
}
}
}