代码:
public class aaa extends JFrame{
aaa(){
this.setSize(205, 150);
this.setVisible(true);
JTextField t1 = new JTextField();
JButton b=new JButton("按钮");
b.setBounds(10, 45, 70, 50);
b.addActionListener(new C());
add(t1);add(b);
}
}
class C implements ActionListener{
public void actionPerformed(ActionEvent e){
String s=t1.getText();
}
}
结果
怎么回事,怎么解决
public class aaa extends JFrame{
aaa(){
this.setSize(205, 150);
this.setVisible(true);
JTextField t1 = new JTextField();
JButton b=new JButton("按钮");
b.setBounds(10, 45, 70, 50);
b.addActionListener(new C());
add(t1);add(b);
}
}
class C implements ActionListener{
public void actionPerformed(ActionEvent e){
String s=t1.getText();
}
}
结果
怎么回事,怎么解决