请帮助我使用此代码文本未出现在文本字段中,尽管它是通过 cmd 提示符但不在文本字段中
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import javax.swing.event.*;
public class listener11
{
private JFrame f;
private JButton b;
private JTextField tf;
public static String str;
public listener11()
{
f=new JFrame("Listener1");
b=new JButton("Press");
b.setActionCommand("Button b1 pressed");
tf=new JTextField(30);
}
public void launchframe()
{
f.setLayout(null);
b.addActionListener(new Buttonlistener());
b.setBounds(200,200,100,100);
tf.setBounds(100,100,200,50);
tf.setText(str);
f.add(b);
f.add(tf);
f.setSize(400,400);
f.setVisible(true);
}
public static void main(String[]arg)
{
listener11 l1=new listener11();
l1.launchframe();
}
}
class Buttonlistener implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
listener11.str="Action took place \n button's command is"+e.getActionCommand();
}
}