Это то, что я пробовал до сих пор:
{
TextField tf;
JTextArea ta;
public TextListener()
{
gui();
}
public void gui()
{
JFrame f = new JFrame();
JPanel p = new JPanel();
tf = new JTextField("",20);
ta = new JTextArea("",20,20);
JButton b = new JButton("SHOW");
f.add(p);
p.add(tf);
p.add(b);
p.add(ta);
f.setVisible(true);
f.setSize(400,200);
f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
}
public void actionPerformed(ActionEvent ae)
{
String name = tf.getText();
ta.append(name);
}
public static void main(String[] arg)
{
new TextListner();
}